Page 119 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 119

Fundamentals of Data Structures




                    Notes
                                          Example: The example given below shows the steps for inserting a Node in Singly
                                   Linked List at the Beginning.
                                       Update the next pointer of new node, to point to the current head.

                                                     Figure 8.2: Update the Next Pointer of New Node









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

                                       Update head pointer to point to the new node.
                                                            Figure 8.3: Update Head Pointer










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

                                   Inserting a Node in Singly Linked List at the Ending

                                   In this case, we need to modify two next pointers (last nodes next pointer and new nodes next
                                   pointer).


                                          Example: The example given below shows the steps for Inserting a Node in Singly
                                   Linked List at the Ending.

                                       New nodes next pointer points to NULL.
                                                           Figure 8.4: New Nodes Next Pointer












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









          112                               LOVELY PROFESSIONAL UNIVERSITY
   114   115   116   117   118   119   120   121   122   123   124