61. 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;
}
#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;
}62. Which of the following is the correct syntax to declare an ArrayList in Java?
63. What is the time complexity for inserting/deleting at the beginning of the array?
64. What is the worst case time complexity of inserting an element into the sorted array?
65. Which of the following algorithm to rotate an array has the maximum time complexity?
66. Which of the following is false?
67. Suffix array of the string "statistics" is . . . . . . . .
68. 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);
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);69. The matrix contains m rows and n columns. The matrix is called Sparse Matrix if . . . . . . . .
70. Both Dynamic array and Dynamically memory allocated array are same.
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.
