Vidyalelo
Data Structure · all questions

Miscellaneous on Data Structures
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

1,171

Questions

44/59

Page

Pick an option on a question to see the right answer and solution.

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; 
}

Select an option to see the answer and solution.

What is meant by the power set of a set?

Select an option to see the answer and solution.

Which of the following is considered as the top of the stack in the linked list implementation of the stack?

Select an option to see the answer and solution.

Which of the following is an application of the minimum cut problem?

Select an option to see the answer and solution.

What is the following expression, lcm (a, lcm (b, c) equal to?

Select an option to see the answer and solution.

A key matrix used for encryption in hill cipher must be?

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

Gronsfeld cipher is similar to?

Select an option to see the answer and solution.

Atbash cipher cannot be cracked until the exact type of encryption of ciphered text is known.

Select an option to see the answer and solution.

Which of the following methods can be used to find the largest and smallest number in a linked list?

Select an option to see the answer and solution.

Who published the extended version of eight queens puzzle?

Select an option to see the answer and solution.

Solve the following recurrence using Master's theorem.
T(n) = 2T (n/2) + n/ log n

Select an option to see the answer and solution.

Consider the following recursive implementation of linear search on a linked list:
struct Node
{
     int val;
     struct Node* next;
}*head;
int linear_search(struct Node *temp,int value)
{
      if(temp == 0)
         return 0;
      if(temp->val == value)
         return 1;
      return _________;
}
Which of the following lines should be inserted to complete the above code?

Select an option to see the answer and solution.

In n-queen problem, how many values of n does not provide an optimal solution?

Select an option to see the answer and solution.

How many cases are there under Master's theorem?

Select an option to see the answer and solution.

Consider the following recursive implementation to find the largest element in an array.
int max_of_two(int a, int b)
{
      if(a > b)
        return a;
      return b;
}
int recursive_max_element(int *arr, int len, int idx)
{
      if(idx == len - 1)
      return arr[idx];
      return _______;
}
Which of the following lines should be inserted to complete the above code?

Select an option to see the answer and solution.

What is the formula to calculate the element present in second row, first column of the product matrix?

Select an option to see the answer and solution.

Which of the following is hardest to break using frequency analysis?

Select an option to see the answer and solution.

Why do we require hamming codes?

Select an option to see the answer and solution.

Which of the following methods used to find the sum of first n natural numbers has the least time complexity?

Select an option to see the answer and solution.