Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

A singly linked list holds 50 -> 31 -> 76 -> 53 -> 96 -> None (in that order, 5 nodes). Using the standard two-pointer technique (advance one pointer 5 nodes ahead, then move both together until the lead pointer reaches None), which value is the 5th node from the end?

  1. A. 50
  2. B. 31
  3. C. 61
  4. D. 60

Correct answer: A. 50

The list has 5 nodes, so the 5-th from the end is at 0-based index 0, which holds 50.

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

Exams that ask this topic