GATE Computer ScienceHardGATE CS (PYQ pattern)

A circular singly linked list holds nodes 1 to 100 in order. Deletion starts with node 1 itself and then removes every second remaining node going round the circle (1, 3, 5, ..., then continuing on the second lap) until one node remains. Which node remains?

  1. A. 73
  2. B. 72
  3. C. 64
  4. D. 100

Correct answer: B. 72

If the deletions started with node 2 (deleting 2, 4, 6, ...) the survivor would be 2(100 - 64) + 1 = 73. Deleting node 1 first is the same process shifted one place back round the circle (the count effectively starts at node 100), so the survivor is the node just before 73: 72. A simulation agrees.

More Programming and Data Structures (GATE) questions

Exams that ask this topic