Data Structures & AlgorithmsHardTCS NQT · Infosys

Two people in a circle of 5 are numbered 1 to 5 and eliminated by repeatedly removing every second person (starting by removing person 2). Which person number survives?

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

Correct answer: A. 3

Removing every second person in a circle is the Josephus problem with k = 2; checking the first few eliminations by hand (2, 4, 1, 5) confirms the survivor.

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

Exams that ask this topic