Arrays In Data Structures MCQs
Practice Arrays In Data Structures MCQs for competitive exams.
Arrays In Data Structures MCQs
Practice questions from this topic.
Which of the following form inversion in the array arr = {1,5,4,2}?
Correct Answer: B
The time complexity of the code that determines the number of inversions in an array using merge sort is lesser than that of the code that uses loops for the same purpose.
Correct Answer: A
What will be the output of the following code? #include using namespace std; void func(int a[], int n, int k) { if (k <= n) { for (int i = 0; i < k/2; i++) swap(a[i], a[k-i-1]); } } int main() { int a[] = {1, 2, 3, 4, 5}; int n = sizeof(a) / sizeof(int), k = 3; func(a, n, k); for (int i = 0; i < n; ++i) cout << a[i]<<" "; return 0; }
Correct Answer: A
What will be the minimum number of jumps required to reach the end of the array arr[] = {1,3,6,3,6,8,5}?
Correct Answer: C
Which class in Java can be used to represent bit array?
Correct Answer: A
What is sparsity of a matrix?
Correct Answer: A
What will be the minimum number of jumps required to reach the end of the array arr[] ={0,1,3,6,3,6,8,5}?
Correct Answer: D
In which of the following cases dynamic arrays are not preferred?
Correct Answer: D
Which of the following bitwise operator will you use to invert all the bits in a bit array?
Correct Answer: B
What will be the output of the following code? #include 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; }
Correct Answer: A
What will be the resulting array after rotating arr[]={1, 2, 3, 4, 5} by 2?
Correct Answer: B
Which of the following is a disadvantage of parallel array over the traditional arrays?
Correct Answer: D
