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
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

What are the expression trees? Represent the below written expression using a tree. Give a relevant comment on the result that you get when this tree is traversed in Preorder,

Let us assume a file of 5 records that means n = 5 And k is a sorted array of keys of those 5 records. Let key = 55, low = 0, high = 4 Iteration 1: mid = (0+4)/2 = 2

A small shop sells 280 different items. Every item is identified by a 3 - digit code. All items which start with a zero (0) are cards, all items which start with a one (1) are swee

state difference between linear and non linear data structure. give one example scenario of each

In the book the following methods are presented: static void selectionSort(Comparable[] list) static void insertionSort(Comparable[] list) static boolean linearSearch(Comparable

Each of the comparison in the binary search decrease the number of possible candidates where the key value can be searched by a factor of 2 as the array is divided into two halves

Write an algorithm for binary search. Algorithm for Binary Search 1.  if (low> high) 2.  return (-1) 3.  Mid = (low + high)/2 4.  if ( X = = a[mid]) 5.  return (mid); 6.

Program gives the program segment by using arrays for the insertion of an element to a queue into the multiqueue. Program: Program segment for the insertion of any element to t

Your first task will be to come up with an appropriate data structure for representing numbers of arbitrary potential length in base 215. You will have to deal with large negative