Midtermproject Sahibul (Graphical Representation)
Midtermproject Sahibul (Graphical Representation)
Insert Operation
Operation: Inserting a new node with the value 5 at the beginning of the list.
Starting List
Step-by-Step Explanation:
● Action: Set the Next pointer of the new node to point to the current head (which is the
node with value 3).
● Annotation: Linking the new node to the existing list is essential for maintaining the
sequential structure of the linked list.
Update Operation
Operation: Updating the node containing the value 7 to 10.
Starting List:
Delete Operation
Operation: Deleting the node containing the value 3.
Initial State
Starting List:
● Action: Start from the head and find the node just before the one to be deleted (node with
value 5).
● Annotation: Identifying the previous node is crucial for adjusting pointers correctly and
maintaining the integrity of the list.
Step 2: Traverse the List
● Action: Move through the list by following the Next pointers until reaching the node with
value 3.
● Annotation: Similar to the update operation, we cannot skip directly to the desired node;
we must traverse from the head.
After Adjustments
Annotation: This pointer adjustment is critical; it ensures the list remains connected without the
deleted node. If not done correctly, we would lose access to parts of the list.
Final List After Deletion
Update Operation:
Finding the desired node by going through the list.
altering the node's data while keeping pointers unchanged.
Delete Operation:
locating the prior node so that it can be adjusted.
updating pointers with care to keep the list consistent.