31. Which is the correct term of the given relation, gcd (a, b) * lcm (a, b) =?
32. A network can have only one source and one sink.
33. What is the output of the following code?
int cnt = 0;
void my_recursive_function(char *s, int i)
{
if(s[i] == '\0')
return;
if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
cnt++;
my_recursive_function(s,i+1);
}
int main()
{
my_recursive_function("thisisrecursion",0);
printf("%d",cnt);
return 0;
}
int cnt = 0;
void my_recursive_function(char *s, int i)
{
if(s[i] == '\0')
return;
if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
cnt++;
my_recursive_function(s,i+1);
}
int main()
{
my_recursive_function("thisisrecursion",0);
printf("%d",cnt);
return 0;
}
34. Which of the following ciphered text would have NOT used transposition cipher for encryption of the plain text "CIPHER"?
35. What is the output for the following code?
#include <bits/stdc++.h>
using namespace std;
void convert(int a[], int n)
{
vector <pair<int, int> > vec;
for (int i = 0; i < n; i++)
vec.push_back(make_pair(a[i], i));
sort(vec.begin(), vec.end());
for (int i=0; i<n; i++)
a[vec[i].second] = i;
}
void printArr(int a[], int n)
{
for (int i=0; i<n; i++)
cout << a[i] << " ";
}
int main()
{
int arr[] = {10,8,2,5,7};
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 a[], int n)
{
vector <pair<int, int> > vec;
for (int i = 0; i < n; i++)
vec.push_back(make_pair(a[i], i));
sort(vec.begin(), vec.end());
for (int i=0; i<n; i++)
a[vec[i].second] = i;
}
void printArr(int a[], int n)
{
for (int i=0; i<n; i++)
cout << a[i] << " ";
}
int main()
{
int arr[] = {10,8,2,5,7};
int n = sizeof(arr)/sizeof(arr[0]);
convert(arr , n);
printArr(arr, n);
return 0;
}
36. What will be the output if quickselect algorithm is applied to the array arr={1, 5, 4, 3, 7} with k given as 4?
37. In a graph, an independent set is maximal if no further vertex can be added to the stay independent.
38. What does the following code do?
#include<stdio.h>
int cnt = 0;
int recursive_search_num(int *arr, int num, int idx, int len)
{
int cnt = 0;
if(idx == len)
return cnt;
if(arr[idx] == num)
cnt++;
return cnt + recursive_search_num(arr, num, idx+1, len);
}
int main()
{
int arr[8] ={0,0,0,0,3,5,-6,7},num = 0,len = 8;
int ans = recursive_search_num(arr,num,0,len);
printf("%d",ans);
return 0;
}
#include<stdio.h>
int cnt = 0;
int recursive_search_num(int *arr, int num, int idx, int len)
{
int cnt = 0;
if(idx == len)
return cnt;
if(arr[idx] == num)
cnt++;
return cnt + recursive_search_num(arr, num, idx+1, len);
}
int main()
{
int arr[8] ={0,0,0,0,3,5,-6,7},num = 0,len = 8;
int ans = recursive_search_num(arr,num,0,len);
printf("%d",ans);
return 0;
}
39. Which of the following methods can be used to solve n-queen's problem?
40. Consider the following code snippet to find the smallest element in a linked list:
struct Node
{
int val;
struct Node* next;
}*head;
int get_min()
{
struct Node* temp = head->next;
int min_num = temp->val;
while(temp != 0)
{
if(_________)
min_num = temp->val;
temp = temp->next;
}
return min_num;
}
Which of the following lines should be inserted to complete the above code?
struct Node
{
int val;
struct Node* next;
}*head;
int get_min()
{
struct Node* temp = head->next;
int min_num = temp->val;
while(temp != 0)
{
if(_________)
min_num = temp->val;
temp = temp->next;
}
return min_num;
}
Which of the following lines should be inserted to complete the above code?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 8
- Miscellaneous on Data Structures - Section 9
- Miscellaneous on Data Structures - Section 10
- Miscellaneous on Data Structures - Section 11
- Miscellaneous on Data Structures - Section 12