Consider the following implementations for rotating an array A[1, ....n] of size n by K positions , where 1 < = K < = n . Note that the procedure reverse (A, i, j) reverses the order of elements in A between positions i and j in A (both inclusive )
which of the above implementation(s) work correctly for all inputs ?
Implementation I:
reverser(A, 1, K);
reverse(A, 1, n) ;
reverse (A, k+1, n) ;
Implementation II:
reverser(a, K+1, n);
reverse(a, 1, K) ;
reverse (a, 1, n) ;
Implementation III:
reverser(a, 1, K);
reverse(a, K+1, n) ;
reverse (a, 1, n) ;