Page 38 - Data Structures Interactive Book
P. 38

4.2   Singly Linked List


                       A singly linked list is the simplest form of linked list, where each node points to the

               next node in the sequence. The last node points to NULL, indicating the end of the list.


                     4.2.1  Creation of Nodes

                       Nodes in a singly linked list are created dynamically using pointers.

                       Example:












                     4.2.2  Traversal


                       Traversal involves visiting each node in the list sequentially, starting from the head.

                       Example:












                     4.2.3  Insertion Operations

                       Insertion  can  occur  at  the  beginning,  end,  or  a  specific  position.  Each  operation

               requires adjusting pointers to maintain the list structure.
                 •  At beginning: new node points to current head, then head is updated.

                 •  At end: traverse to last node, update its pointer to new node.

                 •  At position: traverse to desired location, adjust pointers accordingly.


                     4.2.4  Deletion Operations

                       Deletion involves removing a node and updating pointers to bypass it.

                       •  At beginning: head is updated to point to the next node.


                                                             38
   33   34   35   36   37   38   39   40   41   42   43