Data Structures & AlgorithmsHardGATE CS · TCS NQT

Rotate the list 1, 2, 3, 4, 5, 6, 7 to the right by 10 positions (each rotation moves the last node to the front). What value is at the head?

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

Correct answer: D. 5

Rotation by k is taken modulo the length, so 10 is the same as 3 here. Rotating ten times without the modulus gives the same head but is slower.

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

Exams that ask this topic