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

54/59

Page

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

What is the prime task of the stable marriage problem?

Select an option to see the answer and solution.

What is the approach implemented in 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;
      cin>>n;
      func1(n);
      return 0; 
}

Select an option to see the answer and solution.

Which cipher is represented by the following function?
void Cipher(string msg, string key) 
{ 
	// Get key matrix from the key string 
	int keyMat[3][3]; 
	getKeyMatrix(key, keyMat); 
	int msgVector[3][1]; 	
	for (int i = 0; i <=2; i++) 
		msgVector[i][0] = (msg[i]) % 65; 
	int cipherMat[3][1]; 
	// Following function generates 
	// the encrypted vector 
	encrypt(cipherMat, keyMat, msgVector); 
	string CipherText; 	
	for (int i = 0; i <=2; i++) 
		CipherText += cipherMat[i][0] + 65; 	
	cout  << CipherText; 
}

Select an option to see the answer and solution.

Bifid square combines autokey square with transposition.

Select an option to see the answer and solution.

Given items as {value,weight} pairs {{40, 20},{30, 10},{20, 5}}. The capacity of knapsack=20. Find the maximum value output assuming items to be divisible.

Select an option to see the answer and solution.

A graph has 20 vertices. The maximum number of edges it can have is? (Given it is bipartite)

Select an option to see the answer and solution.

Which of the following best represents the time complexity for inserting an element in coalesced hashing?

Select an option to see the answer and solution.

Which of the following is not an application of inclusion-exclusion principle?

Select an option to see the answer and solution.

What is common between affine cipher and pigpen cipher.

Select an option to see the answer and solution.

What is the time complexity of the following iterative implementation used to find the largest and smallest element in an array?
#include<stdio.h>
int get_max_element(int *arr,int n)
{
      int i, max_element = arr[0];
      for(i = 1; i < n; i++)
        if(arr[i] > max_element)
          max_element = arr[i];
      return max_element;
}
int get_min_element(int *arr, int n)
{
      int i, min_element;
      for(i = 1; i < n; i++)
        if(arr[i] < min_element)
          min_element = arr[i];
      return min_element;
}
int main()
{
     int n = 7, arr[7] = {1,1,1,0,-1,-1,-1};
     int max_element = get_max_element(arr,n);
     int min_element = get_min_element(arr,n);
     printf("%d %d",max_element,min_element);
     return 0;
}

Select an option to see the answer and solution.

The problem of finding a path in a graph that visits every vertex exactly once is called?

Select an option to see the answer and solution.

Who formulated a straight forward backtracking scheme for stable marriage problem?

Select an option to see the answer and solution.

Which of the following is true according to Ramanujan's congruence?

Select an option to see the answer and solution.

What is the output of the following code?
int fact(int n)
{
      if(n == 0)
        return 1;
      return n * fact(n - 1);
}
int main()
{
      int n = 5;
      int ans = fact(n);
      printf("%d",ans);
      return 0;
}

Select an option to see the answer and solution.

Which of the following is not true about set partition problem?

Select an option to see the answer and solution.

Find the output of the following code.
#include <bits/stdc++.h> 
using namespace std; 
void crossP(int A[], int B[], int cross[]) 
{ 
	cross[0] = A[1] * B[2] - A[2] * B[1]; 
	cross[1] = A[0] * B[2] - A[2] * B[0]; 
	cross[2] = A[0] * B[1] - A[1] * B[0]; 
}
int main() 
{ 
	int A[] = { 1, 2, 4 }; 
	int B[] = { 2, 3, 2 }; 
	int cross[3]; 
	crossP(A, B, cross); 
	for (int i = 0; i < 3; i++) 
		cout << cross[i] << " "; 
	return 0; 
}

Select an option to see the answer and solution.

What is the average case time complexity of quickselect?

Select an option to see the answer and solution.

Which of the following is not a type of traditional cipher?

Select an option to see the answer and solution.

Who was the first person to find the solution of Eight Queen Puzzle using determinant?

Select an option to see the answer and solution.

Vigenere cipher is harder to decipher than keyword cipher.

Select an option to see the answer and solution.