Data Structures & AlgorithmsHardGATE CS · TCS NQT

A list holds 1, 2, 3, 4, 5. It is rotated right by 2 positions (the last two nodes move to the front). What is the value of the new head node's successor (the node at position 2)?

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

Correct answer: D. 5

After rotating right by 2 the list is 4, 5, 1, 2, 3, so position 2 holds 5. Rotating left by 2 would instead give position 2 as 3.

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

Exams that ask this topic