GATE CS 2000 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0252

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 \(\leqslant k \leqslant\) n:
reverse (s, 1, k);
reverse (s, k+1, n);
reverse (s, 1, n);
  1. A
    Rotates s left by k positions
  2. B
    Leaves s unchanged
  3. C
    Reverses all elements of s
  4. D
    None of the above

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option A.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/662/gate2000-2-15

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com