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
Handout 15 COMP 264: Introduction to Computer Systems (Section 001) Spring 2013 R. I. Greenberg Computer Science Department Loyola University Water TowerCampus, Lewis Towers 524 82

Define Minimum Spanning Tree A minimum spanning tree of a weighted linked graph is its spanning tree of the smallest weight, where the weight of a tree is explained as the sum

Explain State Space Tree If it is convenient to execute backtracking by constructing a tree of choices being made, the tree is known as a state space tree. Its root indicates a

algorithm for multiple queue with example program

how to reduce the number of passes in selection sort

Q. What do you understand by the term Binary Tree? What is the maximum number of nodes which are possible in a Binary Tree of depth d. Explain the terms given below with respect to

It is a naturally occurring sorting method exemplified through a card player arranging the cards dealt to him. He picks up the cards like they are dealt & added them into the neede

Objective The goal of this project is to extend and implement an algorithm presented in the course and to apply notions introduced by the course to this program/algorithm. The ass

prove that n/100=omega(n)

If a node in a BST has two children, then its inorder predecessor has No right child