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

A singly linked list holds 36 -> 38 -> 51 -> 57 -> 28 -> None (in that order, 5 nodes). Using the standard two-pointer technique (advance one pointer 1 nodes ahead, then move both together until the lead pointer reaches None), which value is the 1st node from the end?

  1. A. 36
  2. B. 28
  3. C. 57
  4. D. 68

Correct answer: B. 28

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

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

Exams that ask this topic