31. What will be the resulting array after reversing arr[]={3,5,4,2}?
32. What will be the auxiliary space complexity of the following code?
#include <iostream>
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;
}
#include <iostream>
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;
}33. What will be the time complexity 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]);
int d = 3;
func(arr, d, n);
printArray(arr, n);
return 0;
}
#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]);
int d = 3;
func(arr, d, n);
printArray(arr, n);
return 0;
}34. What is a sparse array?
35. How will you implement dynamic arrays in Java?
36. Which of the following bitwise operations will you use to set a particular bit to 0?
37. Which of the following arrays are used in the implementation of list data type in python?
38. In what way the Symmetry Sparse Matrix can be stored efficiently?
39. What is the time complexity of the code that uses merge sort for determining the number of inversions in an array?
40. The number of items used by the dynamic array contents is its . . . . . . . .
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.
