91. Which of the following don't use matrices?
92. How many swaps are required for reversing an array having n elements where n is an odd number?
93. What is the space complexity of the code that uses merge sort for determining the number of inversions in an array?
94. What will be the auxiliary space complexity of the code to rotate an array by using the reversal algorithm (d = number of rotations)?
95. What is the time complexity of the code that uses self balancing BST for determining the number of inversions in an array?
96. Array is divided into two parts in . . . . . . . .
97. To search for an element in a sorted array, which searching technique can be used?
98. What will be the output of the following code?
#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int n)
{
int count[n];
memset(count, 0, sizeof(count));
for (int i=n-2; i>=0; i--)
{
if (arr[i] >= n - i - 1)
count[i]++;
for (int j=i+1; j < n-1 && j <= arr[i] + i; j++)
if (count[j] != -1)
count[i] += count[j];
if (count[i] == 0)
count[i] = -1;
}
for (int i=0; i<n; i++)
cout << count[i] << " ";
}
int main()
{
int arr[] = {1, 3, 5, 8, 9};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, n);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int n)
{
int count[n];
memset(count, 0, sizeof(count));
for (int i=n-2; i>=0; i--)
{
if (arr[i] >= n - i - 1)
count[i]++;
for (int j=i+1; j < n-1 && j <= arr[i] + i; j++)
if (count[j] != -1)
count[i] += count[j];
if (count[i] == 0)
count[i] = -1;
}
for (int i=0; i<n; i++)
cout << count[i] << " ";
}
int main()
{
int arr[] = {1, 3, 5, 8, 9};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, n);
return 0;
}99. Run-Length encoding is used to compress data in bit arrays.
100. In how many different ways we can reach the end of the array arr[]={1,3,5,8,9}?
Read More Section(Arrays in Data Structures)
Each Section contains maximum 100 MCQs question on Arrays in Data Structures. To get more questions visit other sections.
