Data Structures & AlgorithmsHardGATE CS · competitive programming

Reverse each complete group of k = 3 nodes in the list 1 → 2 → … → 10, leaving a final incomplete group as it is. What value is at position 7 (1-based)?

  1. A. 9
  2. B. 7
  3. C. 4
  4. D. 6

Correct answer: A. 9

The list becomes 3 2 1 6 5 4 9 8 7 10, so position 7 holds 9. The value 7 is only the trap: it sits at position 9 after the reversals.

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

Exams that ask this topic