61. What is the time complexity of the following code?
#include <bits/stdc++.h>
using namespace std;
void convert(int arr[], int n)
{
int temp[n];
memcpy(temp, arr, n*sizeof(int));
sort(temp, temp + n);
unordered_map<int, int> map;
int sort_index = 0;
for (int i = 0; i < n; i++)
map[temp[i]] = sort_index++;
for (int i = 0; i < n; i++)
arr[i] = map[arr[i]];
}
void printArr(int arr[], int n)
{
for (int i=0; i<n; i++)
cout << arr[i] << " ";
}
int main()
{
int arr[] = {10, 20, 15, 12, 11, 50};
int n = sizeof(arr)/sizeof(arr[0]);
convert(arr , n);
printArr(arr, n);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
void convert(int arr[], int n)
{
int temp[n];
memcpy(temp, arr, n*sizeof(int));
sort(temp, temp + n);
unordered_map<int, int> map;
int sort_index = 0;
for (int i = 0; i < n; i++)
map[temp[i]] = sort_index++;
for (int i = 0; i < n; i++)
arr[i] = map[arr[i]];
}
void printArr(int arr[], int n)
{
for (int i=0; i<n; i++)
cout << arr[i] << " ";
}
int main()
{
int arr[] = {10, 20, 15, 12, 11, 50};
int n = sizeof(arr)/sizeof(arr[0]);
convert(arr , n);
printArr(arr, n);
return 0;
}
62. What is meant by the power set of a set?
63. Which of the following is considered as the top of the stack in the linked list implementation of the stack?
64. Which of the following is an application of the minimum cut problem?
65. What is the following expression, lcm (a, lcm (b, c) equal to?
66. A key matrix used for encryption in hill cipher must be?
67. What is the output of the following code?
#include<stdio.h>
int search_num(int *arr, int num, int len)
{
int i;
for(i = 0; i < len; i++)
if(arr[i] == num)
return i;
return -1;
}
int main()
{
int arr[5] ={1,3,3,3,5},num=3,len = 5;
int indx = search_num(arr,num,len);
printf("Index of %d is %d",num,indx);
return 0;
}
#include<stdio.h>
int search_num(int *arr, int num, int len)
{
int i;
for(i = 0; i < len; i++)
if(arr[i] == num)
return i;
return -1;
}
int main()
{
int arr[5] ={1,3,3,3,5},num=3,len = 5;
int indx = search_num(arr,num,len);
printf("Index of %d is %d",num,indx);
return 0;
}
68. Gronsfeld cipher is similar to?
69. Atbash cipher cannot be cracked until the exact type of encryption of ciphered text is known.
70. Which of the following methods can be used to find the largest and smallest number in a linked list?
Read More Section(Miscellaneous on Data Structures)
Each Section contains maximum 100 MCQs question on Miscellaneous on Data Structures. To get more questions visit other sections.
- Miscellaneous on Data Structures - Section 1
- Miscellaneous on Data Structures - Section 2
- Miscellaneous on Data Structures - Section 3
- Miscellaneous on Data Structures - Section 4
- Miscellaneous on Data Structures - Section 5
- Miscellaneous on Data Structures - Section 6
- Miscellaneous on Data Structures - Section 7
- Miscellaneous on Data Structures - Section 8
- Miscellaneous on Data Structures - Section 10
- Miscellaneous on Data Structures - Section 11
- Miscellaneous on Data Structures - Section 12