Saturday, March 5, 2011

DS- multi linked list

Multi-Linked lists

A multiple linked list has several pointers in each node. They are used to traverse the nodes in different orders, for example one set of links ordered by date of birth and another ordered alphabetically by name.

A list can have two pointers without having a backward pointer. For instance, we may want to keep a set of data ordered on more than one "key". A key is a unique data item included in a record which distinguishes one record from all other records included in the list.  Suppose we want to be able to access customer accounts in order by account number (integer) and by customer name (string). We can in fact have one list that is ordered both ways. We need two pointer fields.  Each node of the list will have the form:

refer: http://frank.mtsu.edu/~csci217/manual/lab10/lab10.html#D

image006.jpg
 
Now, let's assume that we have a class called MultiListClass and that we wish to implement this list with a dummy header node.

 Here is an example list which implements the multi-linked list:

image007.jpg
Insertion and deletion require about twice the work since two sets of pointers must be adjusted: one for the name and one for the account number.  Essentially, you perform the same adjustments as in a singly linked list but you do it twice.

No comments:

Post a Comment