Data Structures & AlgorithmsHardGATE CS · TCS NQT

Given the linked list 1 -> 2 -> ... -> 8, the list is reversed in consecutive groups of 3 (a final group with fewer than 3 nodes is left unchanged). What is the value of the 7th node?

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

Correct answer: B. 7

Groups become [3,2,1], [6,5,4] and [7,8]. The final short group must stay in order, so reversing it wrongly changes the 7th node.

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

Exams that ask this topic