Sign in
Please select an account to continue using cracku.in
↓ →
An array A consists of n integers in locations A[O], A[1] ....A[n-1]. It is required to shift the elements of the array cyclically to the left by k places, where $$1 \leq k \leq (n-1)$$. An incomplete algorithm for doing this in linear time, without using another array is given below. Complete the algorithm byfilling in the blanks. Assume alt the variables are suitably declared.
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 = ...........;
}
Create a FREE account and get:
Book Free CAT Mentorship
Get personalized CAT strategy from a 99%iler
500+ students mentored
OTP Verification
Enter the 6-digit code sent to your phone
Booking Summary
Enter OTP
Didn't receive the OTP?
Start your IIM journey with the right preparation and crack CAT 2026.
Educational materials for CAT preparation