Open In App

Top | MCQs on Array Data Strcuture with Answers | Question 18

Fill in the blanks for completing the program to rotate an array by d elements.




/*Function to left rotate arr[] of size n by d*/
void Rotate(int arr[], int d, int n)
{
    int p = 1;
    while (_______) {
        int last = arr[0];
        for (int i = 0; ______ i++) {
            arr[i] = arr[i + 1];
        }
        __________
        p++;
    }
}

(A)



p <= d , i < n – 1 , arr[n – 1] = last;

(B)



p < d, i < n, arr[n] = last;

(C)

p >=d, i >n , arr[n] =  last

(D)

None


Answer: (A)
Explanation:

In the three blanks given in the questions.

Hence Option(A) is correct.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :
Uncategorized