Write procedure to the insert a node into the linked list, Data Structure & Algorithms

Assignment Help:

Q. Write a procedure to the insert a node into the linked list at a particular position and draw the same by taking an example?                                                                                                       

Ans:

* Insert (after legal position p).*/

/* Header implementation assumed. */

void insert( element_type x, LIST L, position p )

{

position tmp_cell;

tmp_cell = (position) malloc( sizeof (struct node));

if( tmp_cell == NULL )

fatal_error("Out of space!!!");

else

{

tmp_cell->element = x; tmp_cell->next = p->next; p->next = tmp_cell;

}

}

1421_linked list.png


Related Discussions:- Write procedure to the insert a node into the linked list

The best average behaviour, The best average behaviour is shown by  Qui...

The best average behaviour is shown by  Quick Sort

An algorithm to insert a node in beginning of linked list, Q. Write down an...

Q. Write down an algorithm to insert a node in the beginning of the linked list.                         Ans: /* structure containing a link part and link part

Which sorting methods sorting a list which is almost sorted, Which sorting ...

Which sorting methods would be most suitable for sorting a list which is almost sorted  Bubble Sorting method.

If a node having two children is deleted from a binary tree, If a node havi...

If a node having two children is deleted from a binary tree, it is replaced by?? Inorder successor

C++, #What is the pointer

#What is the pointer

For loop, for (i = 0; i sequence of statements } Here, the loop e...

for (i = 0; i sequence of statements } Here, the loop executes n times. Thus, the sequence of statements also executes n times. Since we suppose the time complexity of th

Draw trace table and determine output of number, Draw trace table and deter...

Draw trace table and determine output from the following flowchart using following data: Number = 45, -2, 20.5

FIRST function in the compiler construction, I need a recursive algorithm t...

I need a recursive algorithm to implement the FIRST function to any grammar

Pipeling, Asktypes of pipelining question #Minimum 100 words accepted#

Asktypes of pipelining question #Minimum 100 words accepted#

Efficient way of storing a sparse matrix in memory, Explain an efficient wa...

Explain an efficient way of storing a sparse matrix in memory.   A matrix in which number of zero entries are much higher than the number of non zero entries is called sparse mat

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd