Page 120 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 120

Unit 8: Operations on Linked List




               Last nodes next pointer points to the new node.                                  Notes
                                  Figure 8.5: Last Nodes Next Pointer










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


          Here also we have three cases:
               Deleting the first node
               Deleting the last node

               Deleting an intermediate node
          Deleting the First Node in Singly Linked List

          First node (current head node) is removed from the list. It can be done in two steps.


                 Example: The example given below shows the steps for deleting the first Node in Singly
          Linked List.
               Create a temporary node which will point to same node as that of head.

                                  Figure 8.6: Create a Temporary Node









          Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
          dsame_chap3.pdf
               Now, move the head nodes pointer to the next node and dispose the temporary node.

                         Figure 8.7: Move the Head Nodes Pointer to the Next Node









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




                                           LOVELY PROFESSIONAL UNIVERSITY                                   113
   115   116   117   118   119   120   121   122   123   124   125