Suppose you are given an array s[1..n] and a procedure reverse(s, i, j), which…
GATE · Computer Science · 2000
Suppose you are given an array s[1..n] and a procedure reverse(s, i, j), which reverses the order of elements in s 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);
- A.
Rotates s left by k positions
- B.
Leaves s unchanged
- C.
Reverses all elements of s
- D.
None of the above
Attempted by 431 students.
Show answer
Correct answer: A
Explore the full course: Iocl Engineers Officers Grade A Paper 2
Loading lesson…