Data Structures & AlgorithmsHardTCS Digital · Infosys SP

11 people stand in a circle numbered 1 to 11. Counting starts at person 1, and every 4th person is removed (counting continues from the next person). Simulating with a queue, who survives, and who is removed third?

  1. A. Survivor 9; third removed 1
  2. B. Survivor 10; third removed 1
  3. C. Survivor 10; third removed 5
  4. D. Survivor 9; third removed 8

Correct answer: A. Survivor 9; third removed 1

Rotate the queue k − 1 times and dequeue the next person each round. Removal order: 4, 8, 1, 6, 11, 7, 3, 2, 5, 10, leaving 9.

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

Exams that ask this topic