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

DELETION OPRERATION<br />

TO delete an element from the list, first the pointers are set properly and then<br />

the memory occupied by the node to be deleted is deallocated(freed).<br />

The deletion in the list can take place at the following positions:<br />

at the beginning of the list.<br />

at the end of the list<br />

after a given element<br />

Deletion has two steps:<br />

<strong>1.</strong> Find the record preceding the one to be deleted from the list<br />

2. Do the deletion<br />

DELETING FROM THE BEGINNING OF THE LIST<br />

An element from the beginning of the list can be deleted by following the given<br />

below algorithm<br />

Algorithm<br />

Delete First (START). This algorithm Deletes an elements from the first position<br />

or frent of the linked list.<br />

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

If START = NULL, THEN<br />

Print ‘Linked list empty’<br />

Exit<br />

End if<br />

2. Set PTR = START<br />

3. Set START = STARnext<br />

4. Print, element deleted is, praInfo.<br />

5. free(ptr).<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 109 ‐

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

Saved successfully!

Ooh no, something went wrong!