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 data structure needed for Breadth First Traversal on a graph is Queue

representation of links list in memory

Technique for direct search is    Hashing is the used for direct search.

An AVL tree is a binary search tree that has the given properties: The sub-tree of each of the node differs in height through at most one. Each sub tree will be an AVL tre

Question 1 Write the different characteristics of an algorithm Question 2 Explain in brief the asymptotic notations Question 3 Write an algorithm of insertion sort and e

How many nodes in a tree have no ancestors 1 node in atree have no ancestors.

write an algorithm to sort given numbers in ascending order using bubble sort

With the help of a program and a numerical example explain the Depth First Traversal of a tree.

This question deals with AVL trees. You must use mutable pairs/lists to implement this data structure: (a) Define a procedure called make-avl-tree which makes an AVL tree with o

Explain an efficient method of storing a sparse matrix in memory. Write a module to find the transpose of the sparse matrix stored in this way. A matrix which contains number o