Page 127 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 127

Fundamentals of Data Structures




                    Notes
                                                        Figure 8.20: Move the Head Nodes Pointer












                                   Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
                                   dsame_chap3.pdf

                                   Deleting the Last Node in Doubly Linked List

                                   This operation is a bit trickier, than removing the first node, because algorithm should find a
                                   node, which is previous to the tail first. It can be done in three steps.


                                          Example: The example given below shows the steps for deleting the Last Node in Doubly
                                   Linked List.

                                       Traverse the list and while traversing maintain the previous node address also. By the
                                       time we reach the end of list, we will have two pointers one pointing to the NULL (tail)
                                       and other pointing to the node before tail node.

                                                             Figure 8.21: Traverse the List











                                   Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
                                   dsame_chap3.pdf
                                       Update tail nodes previous nodes next pointer with NULL.

                                                             Figure 8.22: Update Tail Nodes












                                   Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
                                   dsame_chap3.pdf








          120                               LOVELY PROFESSIONAL UNIVERSITY
   122   123   124   125   126   127   128   129   130   131   132