50+ Rotation Array Operation MCQs with FREE PDF

We have the best collection of the Rotation Array Operation MCQs and answer with FREE PDF. These Rotation Array Operation MCQs will help you to prepare for any competitive exams like: BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly.

Rotation Array Operation MCQs

a) O(1)

b) O(n)

c) O(d)

d) O(n*d)

2. Which of the following is the predefined function for array reversal in C++?

a) rotate()

b) arr_rotate()

c) array_rotate()

d) rot()

a) 1

b) 2

c) 3

d) 4

a) math

b) stdio

c) stdlib

d) algorithm

5. Which of the following algorithm to rotate an array has the maximum time complexity?

a) rotate elements one by one

b) juggling algorithm

c) reversal algorithm

d) using a temporary array

Answer: rotate elements one by one

a) O(1)

b) O(n)

c) O(d)

d) O(n*d)

7. What will be the resulting array after rotating arr[]={1, 2, 3, 4, 5} by 2?

a) 2, 1, 3, 4, 5

b) 3, 4, 5, 1, 2

c) 4, 5, 1, 2, 3

d) 1, 2, 3, 5, 4

Answer: 3, 4, 5, 1, 2

8. What will be the output of the following code?

``````#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}
``````

a) 5 6 1 2 3 4

b) 6 5 4 3 1 2

c) 3 4 5 6 1 2

d) error

Answer: 5 6 1 2 3 4

9. What will be the time complexity of the following code?

``````#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}
``````

a) O(d)

b) O(n)

c) O(n2)

d) O(n*d)

10. What will be the auxiliary space complexity of the following code?

``````#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}
``````

a) O(1)

b) O(n)

c) O(d)

d) O(n*d)