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

node are both NULL, indicating the end of the list for each direction.<br />

Same as the linear linked list, the basic operations of double linked list include<br />

insertion, deletion and search. We will discuss them in the following section.<br />

To create an ADT for two‐way linked lists the following operations (at a<br />

minimum) are needed:<br />

• Create: Start a new list with nothing in it.<br />

• Insert: Add a record to the list.<br />

• Delete: Delete a record from the list.<br />

• Get Info: Find and return information from a record in the list.<br />

These operations basically mimic the simple linked list case, except that<br />

additional access variables must be used.<br />

OPERATIONS:<br />

Insertion of Double Linked List:<br />

Insertion is to add a new node into a linked list. It can take place anywhere ‐‐<br />

the first, last, or interior of the linked list.<br />

To add a new node to the head and tail of a double linked list is similiar to the<br />

linear linked list. First, we need to construct a new node that is pointed by<br />

pointer new. Then the new node is linked to the left‐most node (or right‐most<br />

node) in the list. Finally, the Left (or Right) is set to point to the new node.<br />

To add a new node inside a double linked list is much more complicated. Four<br />

links must be attached. The following example will give you the details<br />

Example: Insert a new node to the left of a node pointed by cur in a double<br />

linked list.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!