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

4/9

Page

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

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

Select an option to see the answer and solution.

Which of the following is the correct syntax to declare an ArrayList in Java?

Select an option to see the answer and solution.

What is the time complexity for inserting/deleting at the beginning of the array?

Select an option to see the answer and solution.

What is the worst case time complexity of inserting an element into the sorted array?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of the following is false?

Select an option to see the answer and solution.

Suffix array of the string "statistics" is . . . . . . . .

Select an option to see the answer and solution.

What does the following piece of code do?
for(int i = 0; i < row; i++)
{  
    for(int j = 0; j < column; j++)
    {
        if(i == j)
            sum = sum + (array[i][j]);
    }
}
System.out.println(sum);

Select an option to see the answer and solution.

The matrix contains m rows and n columns. The matrix is called Sparse Matrix if . . . . . . . .

Select an option to see the answer and solution.

Both Dynamic array and Dynamically memory allocated array are same.

Select an option to see the answer and solution.

What is the order of a matrix?

Select an option to see the answer and solution.

Reversal algorithm and juggling algorithm for array rotation have the same time complexity.

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Who coined the term Sparse Matrix?

Select an option to see the answer and solution.

What is the relation between Sparsity and Density of a matrix?

Select an option to see the answer and solution.

Arbitrary expressions can be used while declaring variable-length arrays.

Select an option to see the answer and solution.

How many inversions does a sorted array have?

Select an option to see the answer and solution.

Which of the following can be called a parallel array implementation?

Options are not available for this question.

Select an option to see the answer and solution.

Which of the following is the disadvantage of sparse matrices over normal matrices?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.