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

38/59

Page

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

Hill cipher is an example of . . . . . . . .

Select an option to see the answer and solution.

What is the running time of naive matrix multiplication algorithm?

Select an option to see the answer and solution.

Encryption in running key cipher is done using . . . . . . . .

Select an option to see the answer and solution.

Which of the following gives the value for Ø(180)?

Select an option to see the answer and solution.

You have to find the sum of digits of a number given that the number is always greater than 0. Which of the following base cases can replace the base case for the below code?
#include<stdio.h>
int recursive_sum_of_digits(int n)
{
      if(n == 0)
        return 0;
      return n % 10 + recursive_sum_of_digits(n/10);
}
int main()
{
      int n = 1201;
      int ans = recursive_sum_of_digits(n);
      printf("%d",ans);
      return 0;
}

Select an option to see the answer and solution.

Which of the following cipher is formed by applying columnar transposition cipher twice?

Select an option to see the answer and solution.

Placing n-queens so that no two queens attack each other is called?

Select an option to see the answer and solution.

What is the purpose of using square root decomposition?

Select an option to see the answer and solution.

What is the message length 'k' of a Hamming(7,4) code?

Select an option to see the answer and solution.

What will be the time complexity of the following code?
#include <stdio.h> 
#include <math.h> 
void PowerSet(char *set, int set_size) 
{ 
	unsigned int pow_size = pow(2, set_size); 
	int count, j; 	
	for(count = 0; count < pow_size; count++) 
	{ 
	     for(j = 0; j < set_size; j++) 
	     { 
 
		if(count & (1<<j)) 
			printf("%c", set[j]); 
	     } 
	     printf(","); 
	} 
} 
int main() 
{ 
	char strset[] = {'a','b','c'}; 
	PowerSet(strset, 3); 
	return 0; 
}

Select an option to see the answer and solution.

. . . . . . . . is a family of combinatorial optimization problems in which a graph is partitioned into two or more parts with constraints.

Select an option to see the answer and solution.

Which of the following graphs don't have chromatin number less than or equal to 2?

Select an option to see the answer and solution.

Fractional knapsack problem can be solved in time O(n).

Select an option to see the answer and solution.

Which of the following best represents the time complexity to access an item in the least recently used cache?

Select an option to see the answer and solution.

What will be the worst case time complexity of finding the sum of elements in a given range of (l,r) in an array of size n when we use square root optimization?

Select an option to see the answer and solution.

Function rand() generates unique random numbers every time.

Select an option to see the answer and solution.

What will be output for the given code?
#include<bits/stdc++.h> 
using namespace std; 
string encrypter(string keyword) 
{ 
	string encoded = ""; 	
	bool arr[26] = {0}; 
	for (int i=0; i<keyword.size(); i++) 
	{ 
		if(keyword[i] >= 'A' && keyword[i] <= 'Z') 
		{ 		
			if (arr[keyword[i]-65] == 0) 
			{ 
				encoded += keyword[i]; 
				arr[keyword[i]-65] = 1; 
			} 
		} 
		else if (keyword[i] >= 'a' && keyword[i] <= 'z') 
		{ 
			if (arr[keyword[i]-97] == 0) 
			{ 
				encoded += keyword[i] - 32; 
				alpha[keyword[i]-97] = 1; 
			} 
		} 
	} 
	for (int i=0; i<26; i++) 
	{ 
		if(arr[i] == 0) 
		{ 
			arr[i]=1; 
			encoded += char(i + 65); 
		} 
	} 
	return encoded; 
} 
string ciphertxt(string msg, string encoded) 
{ 
	string cipher=""; 
	for (int i=0; i<msg.size(); i++) 
	{ 
		if (msg[i] >='a' && msg[i] <='z') 
		{ 
			int pos = msg[i] - 97; 
			cipher += encoded[pos]; 
		} 
		else if (msg[i] >='A' && msg[i] <='Z') 
		{ 
			int pos = msg[i] - 65; 
			cipher += encoded[pos]; 
		} 
		else
		{ 
			cipher += msg[i]; 
		} 
	} 
	return cipher; 
} 
int main() 
{ 
	string keyword; 
	keyword = "cipher"; 	
	string encoded = encrypter(keyword); 
	string message = "hello"; 
	cout  << ciphertxt(message,encoded) << endl; 
	return 0; 
}

Select an option to see the answer and solution.

What is the set partition problem?

Select an option to see the answer and solution.

Find the output of the following code.
#include<math.h> 
#include<iostream.h>
using namespace std;
void distance(float x, float y, float a, float b, float c) 
{ 
	float d = fabs((a * x + b * y + c)) / (sqrt(a * a + b * b)); 
	cout<<d;
	return; 
} 
int main() 
{ 
	float x = -2; 
	float y = -3; 
	float a = 5; 
	float b = -2; 
	float c = - 4; 
	distance(x, y, a, b, c); 
	return 0; 
}

Select an option to see the answer and solution.

What will be the plain text corresponding to cipher text "YGQ" if hill cipher is used with keyword as "GYBNQKURP"?

Select an option to see the answer and solution.