Question 11088 – Algorithms
November 19, 2023GATE 2008
November 19, 2023Algorithms
|
Question 10
|
An array A contains 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 is given below. Complete the algorithm by filling in the blanks. Assume
all variables are suitably declared.
min:=n;
i=0;
while _____do
begin
temp:=A[i];
j:=i;
while _____do
begin
A[j]:=_____;
j:=(j+K) mod n;
if j<min then="" min:="j;" end;="" a[(n+i-k)mod="" n]:="_____;" i:="____________;"
|
Theory Explanation.
|
Correct Answer: A
