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

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

Posted Date: 7/11/2012 1:41:27 AM | Location : United States







Related Discussions:- Write procedure to the insert a node into the linked list, Assignment Help, Ask Question on Write procedure to the insert a node into the linked list, Get Answer, Expert's Help, Write procedure to the insert a node into the linked list Discussions

Write discussion on Write procedure to the insert a node into the linked list
Your posts are moderated
Related Questions
The quick sort algorithm exploit design technique Divide and Conquer

Q. Explain the basic concept of the primitive data structures.                                             Ans. The concept of P r i m i t i ve Data

advanatges of dynamic data structure in programming

Link list representation of a circular queue is more efficient as it employs space more competently, of course with the added cost of storing the pointers. Program 7 gives the link

Approximating smooth surfaces with Polygon nets Networks of polygons are used to represent smooth surfaces. They are, of course, only an approximation to the true surface, but

A LGORITHM (Deletion of an element from the linked list) Step 1  Begin Step 2  if the list is empty, then element cannot be deleted Step 3  else, if the element to be del

Document processing is quickly becoming one of the dominant functions of computers. Computers are utilized to edit, search & transport documents over the Internet, and to display d

A binary tree is a tree data structures in which each node have at most two child nodes, generally distinguished as "right" and "left". Nodes with children are called parent nodes,

5. Implement a stack (write pseudo-code for STACK-EMPTY, PUSH, and POP) using a singly linked list L. The operations PUSH and POP should still take O(1) time.

Draw trace table and determine output from the subsequent flowchart using below data:  X = 5, -3, 0, -3, 7, 0, 6, -11, -7, 12