• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

ISRO | ISRO CS 2018 | Question 24

An array A consists of n integers in locations A[0], A[1] ....A[n-1]. It is required to shift the elements of the array cyclically to the left by k places, where 1 <= k <= (n-1). An incomplete algorithm for doing this in linear time, without using another array is given below. Complete the algorithm by filling in the blanks. Assume alt the variables are suitably declared.

C++
min = n; i = 0;

while (___________) {	

     temp = A[i]; j = i;

     while (________) {

     A[j] = ________	

     j= (j + k) mod n ;

     If ( j< min ) then

         min = j;

}

A[(n + i  k) mod n] = _________

i = __________

(A)

i > min; j!= (n+i)mod n; A[j + k]; temp; i + 1 ;

(B)

i < min; j!= (n+i)mod n; A[j + k]; temp; i + 1;

(C)

i > min; j!= (n+i+k)mod n; A[(j + k)]; temp; i + 1;

(D)

i < min; j!= (n+i-k)mod n; A[(j + k)mod n]; temp; i + 1;

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments