Algorithms | Misc | Question 8

Last Updated :
Discuss
Comments
Suppose you are given an array s[1...n] and a procedure reverse (s,i,j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence
do, where 1 < k <= n:
  reverse (s, 1, k);
  reverse (s, k + 1, n);
  reverse (s, 1, n);
(GATE CS 2000)
Rotates s left by k positions
Leaves s unchanged
Reverses all elements of s
None of the above
Share your thoughts in the comments