Question:

Suppose you are given pointers to the first and the last nodes of a singly linked list, which one of the following operations would require traversal of the linked list?

Show Hint

In a singly linked list, operations involving the previous node require traversal.
Updated On: Feb 8, 2026
  • Delete the first node
  • Insert a new node as the first node of the list
  • Delete the last node of the list
  • Insert a new node at the end of the list
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Understanding singly linked lists.
In a singly linked list, each node contains a data field and a pointer to the next node only. There is no pointer to the previous node.
Step 2: Analyzing given operations.
- Deleting the first node requires only updating the head pointer.
- Inserting at the beginning requires only updating the head pointer.
- Inserting at the end can be done directly using the tail pointer.
Step 3: Identifying the operation requiring traversal.
To delete the last node, we must find the second-last node so that its next pointer can be set to \texttt{NULL}. This requires traversing the list from the head.
Step 4: Final conclusion.
Therefore, deleting the last node of a singly linked list requires traversal.
Was this answer helpful?
0
0