10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

INSETING A NODE AT THE SPECIFIED POSITION<br />

TO insert the new element after the given element, first we find the<br />

location, say loc, of the given element in the list, and then the element is<br />

inserted in the list<br />

Algorithm<br />

INSERT_LOCATION(START, item, loc).This algorithm inserts an item at the<br />

specified position in the linked list.<br />

<strong>1.</strong>[check for overflow ?]<br />

if PTR= = NULL, then<br />

print ‘overflow’<br />

exit<br />

else<br />

PTR=(Node *) malloc (size of(node))<br />

END if<br />

2. Set PTRINFO= Item<br />

3. If start= NULL then<br />

Set start=p<br />

Set next=NULL<br />

END if<br />

4.Initialise the counter(I) and pointers<br />

(Node * temp)<br />

set I=0<br />

set temp= START<br />

5. Repeat step 6 and 7 untill I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!