We're given pointers to both the first and last nodes of a singly linked list, and asked which operation still needs a full traversal despite having both ends directly accessible. In a singly linked list, each node only points forward, there is no link back to a previous node.
- Delete the first node: The head pointer is simply moved to point to the second node (accessible via the current first node's next pointer), and the old first node is freed. No traversal is needed since we already hold the first node directly.
- Insert a new node as the first node: The new node's next pointer is set to the current first node, and the head pointer is updated to the new node. This is a constant-time operation using the head pointer alone.
- Delete the last node: Removing the last node means the new last node (the second-to-last one) must have its next pointer set to null, and the tail pointer updated to it. But a singly linked list has no backward pointer, so the only way to find "the node just before the last one" is to start at the head and walk forward until reaching it, a full traversal.
- Insert a new node at the end: Since the tail pointer already points directly to the last node, the new node can be attached to its next field and the tail pointer updated to the new node, all without walking the list.
Every operation except one can be done directly through the head or tail pointer alone; the exception is the one that needs to locate a node's predecessor, which a singly linked list can't do without walking from the start.
Therefore, the correct answer is Delete the last node of the list.