Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. 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);
    1. Rotates s left by k positions
    2. Leaves s unchanged
    3. Reverses all elements of s
    4. None of these
Correct Option: A

From the given conditions it can be clearly concluded that, the given sequence rotates s left by k positions.



Your comments will be displayed only after manual approval.