Vidyalelo
Data Structure · all questions

Arrays in Data Structures
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

176

Questions

3/9

Page

Pick an option on a question to see the right answer and solution.

Which of the following data structures is best suited for implementing an array list in Java?

Select an option to see the answer and solution.

How do you find the maximum element in an array in Python?

Select an option to see the answer and solution.

What happens when you access an array element out of bounds in C++?

Select an option to see the answer and solution.

How do you copy an array in C++?

Select an option to see the answer and solution.

Which of the following is a correct way to declare a constant array in JavaScript?

Select an option to see the answer and solution.

Which matrix has most of the elements (not all) as Zero?

Select an option to see the answer and solution.

It is not possible to find the minimum number of steps to reach the end of an array in linear time.

Select an option to see the answer and solution.

What is the time complexity of the following code that determines the number of inversions in an array?
int InvCount(int arr[], int n) 
{ 
	int count = 0; 
	for (int i = 0; i < n - 1; i++) 
		for (int j = i + 1; j < n; j++) 
			if (arr[i] > arr[j]) 
				count++; 
 
	return count; 
}

Select an option to see the answer and solution.

If column-major order is used, how is the following matrix stored in memory?
a b c
d e f
g h i

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the suffix array of the string "engineering"?

Select an option to see the answer and solution.

Where does the GNU C compiler allocates memory for variable-length arrays?

Select an option to see the answer and solution.

Which of the following is not an application of sorted array?

Select an option to see the answer and solution.

What is a bit array?

Select an option to see the answer and solution.

Which of the following bitwise operations will you use to set a particular bit to 1?

Select an option to see the answer and solution.

What are parallel arrays?

Select an option to see the answer and solution.

Which of the following is an advantage of parallel arrays?

Select an option to see the answer and solution.

Which of the following is an advantage of matrices?

Select an option to see the answer and solution.

What will be the output of the following code?
#include <bits/stdc++.h> 
using namespace std; 
 
void func1(int arr[], int n) 
{ 
	int k = arr[0], i; 
	for (i = 0; i < n - 1; i++) 
		arr[i] = arr[i + 1]; 
 
	arr[i] = k; 
} 
 
void func(int arr[], int d, int n) 
{ 
	for (int i = 0; i < d; i++) 
		func1(arr, n); 
} 
 
void printArray(int arr[], int n) 
{ 
	for (int i = 0; i < n; i++) 
		cout << arr[i] << " "; 
} 
 
int main() 
{ 
	int arr[] = { 1, 2, 3, 4, 5}; 
	int n = sizeof(arr) / sizeof(arr[0]); 
 
 
	func(arr, 3, n); 
	printArray(arr, n); 
 
	return 0; 
}

Select an option to see the answer and solution.

Which of the following is not a disadvantage of bit array?

Select an option to see the answer and solution.