61. What is the prime task of the stable marriage problem?
62. 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;
}
#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;
}
63. 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;
}
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;
}
64. Bifid square combines autokey square with transposition.
65. 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.
66. A graph has 20 vertices. The maximum number of edges it can have is? (Given it is bipartite)
67. Which of the following best represents the time complexity for inserting an element in coalesced hashing?
68. Which of the following is not an application of inclusion-exclusion principle?
69. What is common between affine cipher and pigpen cipher.
70. 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;
}
#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;
}
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 8
- Miscellaneous on Data Structures - Section 9
- Miscellaneous on Data Structures - Section 10
- Miscellaneous on Data Structures - Section 12