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

18/59

Page

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

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

Select an option to see the answer and solution.

The random page replacement algorithm fares better than which of the following algorithm?

Select an option to see the answer and solution.

Set partition problem is an example of NP complete problem.

Select an option to see the answer and solution.

Which letter of the English alphabet has the shortest code in Morse Code?

Select an option to see the answer and solution.

Given the program of naive method.
for i=1 to n do
   for j=1 to n do
       Z[i][j]=0;
       for k=1 to n do 
            ___________________________
Fill in the blanks with appropriate formula

Select an option to see the answer and solution.

What will be the slope of the line given by ax + by + c = 0?

Select an option to see the answer and solution.

The first step in the naive greedy algorithm is?

Select an option to see the answer and solution.

In divide and conquer, the time is taken for merging the subproblems is?

Select an option to see the answer and solution.

Is 9 and 28 coprime number?

Select an option to see the answer and solution.

What is the output of the following code?
#include<iostream> 
using namespace std;  
void printArray(int p[], int n) 
{ 
	for (int i = 0; i <= n-1; i++) 
	cout << p[i] << " "; 
	cout << endl; 
} 
void func1(int n) 
{ 
	int p[n];  
	int k = 0;  
	p[k] = n; 	
	while (true) 
	{ 		
		printArray(p, k+1); 		
		int rem_val = 0; 
		while (k >= 0 && p[k] == 1) 
		{ 
			rem_val += p[k]; 
			k--; 
		} 
		if (k < 0) return; 	
		p[k]--; 
		rem_val++; 		
		while (rem_val > p[k]) 
		{ 
			p[k+1] = p[k]; 
			rem_val = rem_val - p[k]; 
			k++; 
		} 
		p[k+1] = rem_val; 
		k++; 
	} 
} 
int main() 
{ 
int n=3;
	func1(n);
	return 0; 
}

Options are not available for this question.

Select an option to see the answer and solution.

Consider the following recursive implementation of the binary search:
#include<stdio.h>
int recursive_binary_search(int *arr, int num, int lo, int hi)
{
      if(lo > hi)
       return -1;
      int mid = (lo + hi)/2;
      if(arr[mid] == num)
      return mid;
      else if(arr[mid] < num)
          __________;
      else
          hi = mid - 1;
     return recursive_binary_search(arr, num, lo, hi);
}
int main()
{
      int arr[8] ={0,0,0,0,3,5,6,7},num = 7,len = 8;
      int indx = recursive_binary_search(arr,num,0,len-1);
      printf("Index of %d is %d",num,indx);
      return 0;
}
Which of the following lines should be added to complete the above code?

Select an option to see the answer and solution.

What is the optimal time required for solving the closest pair problem using divide and conquer approach?

Select an option to see the answer and solution.

Running key cipher is a transposition cipher.

Select an option to see the answer and solution.

Which among the following is an application of the least recently used algorithm?

Select an option to see the answer and solution.

What will be the output of the following code?
void my_recursive_function(int n)
{
    if(n == 0)
    {
         printf("False");
	   return;
    }
    if(n == 1)
    {
         printf("True");
         return;
    }
    if(n%2==0)
    my_recursive_function(n/2);
    else
    {
         printf("False");
         return;
    }
 
}
int main()
{
     my_recursive_function(100);
     return 0;
}

Select an option to see the answer and solution.

What should be the return type of rand() function?

Select an option to see the answer and solution.

hat is the correct formula for generating random numbers in the range (lower,upper) using rand()?

Select an option to see the answer and solution.

What will be the plain text corresponding to cipher text "XKS" if the bifid cipher is used with key as "KEY" and period as 5?

Select an option to see the answer and solution.

What is the LCM according to the given Venn Diagram?
Miscellaneous on Data Structures mcq question image

Select an option to see the answer and solution.

What will be the worst case time complexity of code to find sum in given query range (l,r) in an array of size n with q number of such queries when we apply MO's algorithm?

Select an option to see the answer and solution.