51. . . . . . . . . is a family of combinatorial optimization problems in which a graph is partitioned into two or more parts with constraints.
52. Which of the following graphs don't have chromatin number less than or equal to 2?
53. Fractional knapsack problem can be solved in time O(n).
54. Which of the following best represents the time complexity to access an item in the least recently used cache?
55. 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?
56. Function rand() generates unique random numbers every time.
57. 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;
}
#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;
}
58. What is the set partition problem?
59. 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;
}
#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;
}
60. What will be the plain text corresponding to cipher text "YGQ" if hill cipher is used with keyword as "GYBNQKURP"?
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 6
- Miscellaneous on Data Structures - Section 7
- Miscellaneous on Data Structures - Section 9
- Miscellaneous on Data Structures - Section 10
- Miscellaneous on Data Structures - Section 11
- Miscellaneous on Data Structures - Section 12