In a circular linked list, among the nodes that remain in the list, which…
2025
In a circular linked list, among the nodes that remain in the list, which node's next pointer is set to NULL during deletion of the last node?
Answer: B. None of the nodes — Concept: A circular linked list is defined by one invariant: every node's next pointer always points to another node inside the same list — including the last…
- A.
Head node
- B.
None of the nodes
- C.
Last node
- D.
Node before last node
Attempted by 324 students.
Show answer & explanation
Correct answer: B
Concept: A circular linked list is defined by one invariant: every node's next pointer always points to another node inside the same list — including the last node, whose next points back to the head — so at no point does any node's next ever hold NULL. This is exactly what distinguishes a circular list from a linear, NULL-terminated list.
Application: trace the deletion on a concrete 3-node circular list A → B → C → (back to A), where C is currently the last node:
Locate the node whose
nextcurrently points at the last node C — here that is B, the second-to-last node.Deallocate C from memory; C is no longer part of the list once this step completes.
Redirect B's
nextpointer away from the removed C and toward the head node A, so B becomes the new last node and the loop stays unbroken.At every step, the pointer that changes (B's
next) is set to point at another node (A), never toNULL; the only pointer removed from existence altogether is C's own, along with C itself.
Cross-check: Contrast this with a linear (non-circular) list, where deleting the tail sets the new tail's next to NULL because the list must terminate somewhere. A circular list never terminates, so this deletion — or the deletion of any node — never introduces a NULL pointer into the structure; the affected pointer is always retargeted to another node, never cleared.
Edge case: if the head node itself happens to be the node immediately before the last node — which happens only when exactly two nodes remain — deleting the last node redirects the head's own next pointer to itself, forming a one-node loop. That pointer still targets a valid node (itself), so it is still never NULL.
This also resolves why 'Last node' is not the answer here: some implementations additionally clear a node's own next pointer to NULL as a defensive step immediately before freeing it, but that node is no longer part of the list once it is deleted — so this is a detail of deallocated memory, not a next pointer belonging to any node that remains in the circular list. The question asks about nodes within the list, where the 'no NULL pointer' invariant always holds.