51. What is the output of the following code?
#include<stdio.h>
#include<stdlib.h>
struct Node
{
int val;
struct Node* next;
}*head;
int get_max()
{
struct Node* temp = head->next;
int max_num = temp->val;
while(temp != 0)
{
if(temp->val > max_num)
max_num = temp->val;
temp = temp->next;
}
return max_num;
}
int get_min()
{
struct Node* temp = head->next;
int min_num = temp->val;
while(temp != 0)
{
if(temp->val < min_num)
min_num = temp->val;
temp = temp->next;
}
return min_num;
}
int main()
{
int i, n = 9, arr[9] ={8,3,3,4,5,2,5,6,7};
struct Node *temp, *newNode;
head = (struct Node*)malloc(sizeof(struct Node));
head -> next =0;
temp = head;
for(i=0;i<n;i++)
{
newNode =(struct Node*)malloc(sizeof(struct Node));
newNode->next = 0;
newNode->val = arr[i];
temp->next =newNode;
temp = temp->next;
}
int max_num = get_max();
int min_num = get_min();
printf("%d %d",max_num,min_num);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
struct Node
{
int val;
struct Node* next;
}*head;
int get_max()
{
struct Node* temp = head->next;
int max_num = temp->val;
while(temp != 0)
{
if(temp->val > max_num)
max_num = temp->val;
temp = temp->next;
}
return max_num;
}
int get_min()
{
struct Node* temp = head->next;
int min_num = temp->val;
while(temp != 0)
{
if(temp->val < min_num)
min_num = temp->val;
temp = temp->next;
}
return min_num;
}
int main()
{
int i, n = 9, arr[9] ={8,3,3,4,5,2,5,6,7};
struct Node *temp, *newNode;
head = (struct Node*)malloc(sizeof(struct Node));
head -> next =0;
temp = head;
for(i=0;i<n;i++)
{
newNode =(struct Node*)malloc(sizeof(struct Node));
newNode->next = 0;
newNode->val = arr[i];
temp->next =newNode;
temp = temp->next;
}
int max_num = get_max();
int min_num = get_min();
printf("%d %d",max_num,min_num);
return 0;
}
52. What will be the chromatic number for an empty graph having n vertices?
53. Heap's algorithm requires an auxiliary array to create permutations.
54. What is the output of the following code?
void my_recursive_function(int n)
{
if(n == 0)
return;
printf("%d ",n);
my_recursive_function(n-1);
}
int main()
{
my_recursive_function(10);
return 0;
}
void my_recursive_function(int n)
{
if(n == 0)
return;
printf("%d ",n);
my_recursive_function(n-1);
}
int main()
{
my_recursive_function(10);
return 0;
}
55. Which of the following algorithm can be used to solve the Hamiltonian path problem efficiently?
56. Is lcm an associative function.
57. What will be the time complexity of the given code?
#include <stdio.h>
#include <string.h>
#include <iostream.h>
using namespace std;
void swap(char *x, char *y)
{
char temp;
temp = *x;
*x = *y;
*y = temp;
}
void func(char *a, int l, int r)
{
int i;
if (l == r)
cout<<a<<” ,”;
else
{
for (i = l; i <= r; i++)
{
swap((a+l), (a+i));
func(a, l+1, r);
swap((a+l), (a+i));
}
}
}
int main()
{
char str[] = "AB";
int n = strlen(str);
func(str, 0, n-1);
return 0;
}
#include <stdio.h>
#include <string.h>
#include <iostream.h>
using namespace std;
void swap(char *x, char *y)
{
char temp;
temp = *x;
*x = *y;
*y = temp;
}
void func(char *a, int l, int r)
{
int i;
if (l == r)
cout<<a<<” ,”;
else
{
for (i = l; i <= r; i++)
{
swap((a+l), (a+i));
func(a, l+1, r);
swap((a+l), (a+i));
}
}
}
int main()
{
char str[] = "AB";
int n = strlen(str);
func(str, 0, n-1);
return 0;
}
58. Square root decomposition technique is only applicable when the number of indices in an array is a perfect square.
59. What is the minimum dominating set of the binary tree given below?

60. Given below is the pseudocode of floyd's cycle detection algorithm. Which of the following best suits the blank?
Start traversing the linked list using two pointers
move one pointer with . . . . . . . .
if pointers meet at any node
{
loop exists in the linked list
}
else
{
linked list doesn’t have a loop
}
Start traversing the linked list using two pointers
move one pointer with . . . . . . . .
if pointers meet at any node
{
loop exists in the linked list
}
else
{
linked list doesn’t have a loop
}
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 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 9
- Miscellaneous on Data Structures - Section 10
- Miscellaneous on Data Structures - Section 11
- Miscellaneous on Data Structures - Section 12