Data Structures & AlgorithmsModerateTCS Digital · Infosys SP

The array [1, 2, 3, 4, 5, 6, 7, 8] is rotated RIGHT by 3 positions and then LEFT by 4 positions. What is the final array?

  1. A. [5, 6, 7, 8, 1, 2, 3, 4]
  2. B. [8, 1, 2, 3, 4, 5, 6, 7]
  3. C. [2, 3, 4, 5, 6, 7, 8, 1]
  4. D. [6, 7, 8, 1, 2, 3, 4, 5]

Correct answer: C. [2, 3, 4, 5, 6, 7, 8, 1]

The net effect is a left rotation by (4 − 3) mod 8 = 1, so the array starts at element 2: [2, 3, 4, 5, 6, 7, 8, 1].

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

Exams that ask this topic