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

1. What will be the auxiliary space complexity of the code to rotate an array by using the reversal algorithm (d = number of rotations)?

a) O(1)

b) O(n)

c) O(d)

d) O(n*d)

Answer: O(1)

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

a) rotate()

b) arr_rotate()

c) array_rotate()

d) rot()

Answer: rotate()

3. How many arguments are required by the predefined function rotate() in C++?

a) 1

b) 2

c) 3

d) 4

Answer: 3

4. Predefined function rotate() in C++ is available under which header file?

a) math

b) stdio

c) stdlib

d) algorithm

Answer: 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

6. What is the time complexity of the juggling algorithm to rotate an array?

a) O(1)

b) O(n)

c) O(d)

d) O(n*d)

Answer: O(n)

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)

Answer: O(n)

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)

Answer: O(d)

Rotation Array Operation MCQs PDF Download

Also Read about Arrays Types

50+ Bit Array MCQs with FREE PDF
50+ Dynamic Array MCQs with FREE PDF
50+ Parallel Array MCQs with FREE PDF
50+ Sparse Array MCQs with FREE PDF
50+ Suffix Array MCQs with FREE PDF
50+ Matrix MCQs with FREE PDF
50+ Sparse Matrix MCQs with FREE PDF
50+ Count Inversion MCQs with FREE PDF
50+ Reversal Array Operation MCQs with FREE PDF
50+ Number of Jumps to Reach End-array Operation MCQs with FREE PDF

1000+ Data Structure MCQs

Abstract Data Types
Application of Stacks
Arrays Types
Types of Lists
Binary Trees
B-Trees
Trees
Heap
Trie
Hash Tables
Graph


Categories: Arrays Types