GATE Computer ScienceVery hardGATE CSE · NIELIT

Thirteen people numbered 1 to 13 stand in a circle (circular linked list). Starting the count at person 1 (who counts as 1), every 4th person is removed and counting resumes from the next person. Which person survives?

  1. A. 6
  2. B. 4
  3. C. 5
  4. D. 8

Correct answer: C. 5

Josephus recurrence J(n) = (J(n−1) + 4) mod n with J(1)=0 (0-based) gives 4, i.e. person 5.

More Programming and Data Structures (GATE) questions

Exams that ask this topic