Data Structures & AlgorithmsVery hard

In iterative reversal of a singly linked list, which pointer must be saved BEFORE the current node's next pointer is changed?

  1. A. The head of the list.
  2. B. The original next pointer of the current node.
  3. C. The previous node's previous pointer.
  4. D. The tail of the list.

Correct answer: B. The original next pointer of the current node.

Re-pointing next overwrites the only link to the rest of the list, so the original next must be stored in a temporary variable first. Otherwise the remaining nodes become unreachable.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic