61. Which of the following is the biggest advantage of selection sort?
62. Minimum cut algorithm comes along with the maximum flow problem.
63. Consider the following code snippet to find the largest element in a linked list:
struct Node{
int val;
struct Node *next;
}*head;
int get_max()
{
struct Node* temp = head->next;
int max_num = temp->val;
while(______)
{
if(temp->val > max_num)
max_num = temp->val;
temp = temp->next;
}
return max_num;
}
Which of the following lines should be inserted to complete the above code?
struct Node{
int val;
struct Node *next;
}*head;
int get_max()
{
struct Node* temp = head->next;
int max_num = temp->val;
while(______)
{
if(temp->val > max_num)
max_num = temp->val;
temp = temp->next;
}
return max_num;
}
Which of the following lines should be inserted to complete the above code?64. Flooding algorithm requires all the network information before implementation.
65. Who formulated the first ever algorithm for solving the Hamiltonian path problem?
66. What is the output of the following code in python, if the input is given as 8?
def CatalanNumber(n):
if n<= 1 :
return 1
result=0
for x in range(n):
result = result + CatalanNumber(x) * CatalanNumber(n-x-1)
return result
n=int(input("Enter the number:"))
answer=CatalanNumber(n)
print(" ", answer)
def CatalanNumber(n):
if n<= 1 :
return 1
result=0
for x in range(n):
result = result + CatalanNumber(x) * CatalanNumber(n-x-1)
return result
n=int(input("Enter the number:"))
answer=CatalanNumber(n)
print(" ", answer)
67. What will be the output for the given code?
#include <stdio.h>
#include <stdbool.h>
bool func1(int arr[], int n, int sum)
{
if (sum == 0)
return true;
if (n == 0 && sum != 0)
return false;
if (arr[n-1] > sum)
return func1(arr, n-1, sum);
return func1(arr, n-1, sum) || func1(arr, n-1, sum-arr[n-1]);
}
bool func (int arr[], int n)
{
int sum = 0;
for (int i = 0; i < n; i++)
sum += arr[i];
if (sum%2 != 0)
return false;
return func1 (arr, n, sum/2);
}
int main()
{
int arr[] = {4,6, 12, 2};
int n = sizeof(arr)/sizeof(arr[0]);
if (func(arr, n) == true)
printf("true");
else
printf("false");
return 0;
}
#include <stdio.h>
#include <stdbool.h>
bool func1(int arr[], int n, int sum)
{
if (sum == 0)
return true;
if (n == 0 && sum != 0)
return false;
if (arr[n-1] > sum)
return func1(arr, n-1, sum);
return func1(arr, n-1, sum) || func1(arr, n-1, sum-arr[n-1]);
}
bool func (int arr[], int n)
{
int sum = 0;
for (int i = 0; i < n; i++)
sum += arr[i];
if (sum%2 != 0)
return false;
return func1 (arr, n, sum/2);
}
int main()
{
int arr[] = {4,6, 12, 2};
int n = sizeof(arr)/sizeof(arr[0]);
if (func(arr, n) == true)
printf("true");
else
printf("false");
return 0;
}
68. Consider the following recursive implementation used to reverse a string:
void recursive_reverse_string(char *s, int left, int right)
{
if(left < right)
{
char tmp = s[left];
s[left] = s[right];
s[right] = tmp;
_________;
}
}
Which of the following lines should be inserted to complete the above code?
void recursive_reverse_string(char *s, int left, int right)
{
if(left < right)
{
char tmp = s[left];
s[left] = s[right];
s[right] = tmp;
_________;
}
}
Which of the following lines should be inserted to complete the above code?69. Most Efficient Time Complexity of Topological Sorting is? (V - number of vertices, E - number of edges)
70. What is the total number of iterations used in a maximum- matching algorithm?
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 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