Page 124 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 124

Unit 8: Operations on Linked List




               Update head nodes left pointer to point to the new node and make new node as head.  Notes
                               Figure 8.14: Update Head Nodes Left Pointer











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

          Inserting a Node in Doubly Linked List at the Ending

          In this case, traverse the list till the end and insert the new node.
               New node right pointer points to NULL and left pointer points to the end of the list.

                            Figure 8.15: New Node Right Pointer Points to NULL











          Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
          dsame_chap3.pdf
               Update right of pointer of last node to point to new node.

                                  Figure 8.16: Update Right of Pointer










          Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
          dsame_chap3.pdf
          Inserting a Node in Doubly Linked List at the Middle

          As discussed in singly linked lists, traverse the list till the position node and insert the new node.

               New node right pointer points to the next node of the position node where we want to
               insert the new node.



             Did u know? New node left pointer points to the position node.






                                           LOVELY PROFESSIONAL UNIVERSITY                                   117
   119   120   121   122   123   124   125   126   127   128   129