31. Recursive solution of Set partition problem is faster than dynamic problem solution in terms of time complexity.
32. What is the output of the following 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 = 1234321;
int ans = recursive_sum_of_digits(n);
printf("%d",ans);
return 0;
}
#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 = 1234321;
int ans = recursive_sum_of_digits(n);
printf("%d",ans);
return 0;
}
33. Consider the following iterative implementation to find the factorial of a number. Which of the lines should be inserted to complete the below code?
int main()
{
int n = 6, i;
int fact = 1;
for(i=1;i<=n;i++)
_________;
printf("%d",fact);
return 0;
}
int main()
{
int n = 6, i;
int fact = 1;
for(i=1;i<=n;i++)
_________;
printf("%d",fact);
return 0;
}
34. What is the basic operation of closest pair algorithm using brute force technique?
35. Which of the following is not a type of transposition cipher?
36. The running time of implementing naive solution to min-cut problem is?
37. Which of the following is not a poly alphabetic substitution cipher?
38. What is the result of the recurrences which fall under first case of Master's theorem (let the recurrence be given by T(n)=aT(n/b)+f(n) and f(n)=nc?
39. What will be the encrypted text corresponding to plain text "CLASSIFIED" using columnar transposition cipher with a keyword as "GAMES"?
40. What will be the output for the following code?
#include <stdio.h>
void combination(int arr[], int aux[], int start, int end, int index, int r);
void print(int arr[], int n, int r)
{
int aux[r];
combination(arr, aux, 0, n-1, 0, r);
}
void combination(int arr[], int aux[], int start, int end, int index, int r)
{
if (index == r)
{
for (int j=0; j<r; j++)
printf("%d ", aux[j]);
printf(", ");
return;
}
for (int i=start; i<=end && end-i+1 >= r-index; i++)
{ aux[index] = arr[i];
combination(arr, aux, i+1, end, index+1, r);
}
}
int main()
{
int arr[] = {1, 2, 3};
int r = 2;
int n = sizeof(arr)/sizeof(arr[0]);
print(arr, n, r);
}
#include <stdio.h>
void combination(int arr[], int aux[], int start, int end, int index, int r);
void print(int arr[], int n, int r)
{
int aux[r];
combination(arr, aux, 0, n-1, 0, r);
}
void combination(int arr[], int aux[], int start, int end, int index, int r)
{
if (index == r)
{
for (int j=0; j<r; j++)
printf("%d ", aux[j]);
printf(", ");
return;
}
for (int i=start; i<=end && end-i+1 >= r-index; i++)
{ aux[index] = arr[i];
combination(arr, aux, i+1, end, index+1, r);
}
}
int main()
{
int arr[] = {1, 2, 3};
int r = 2;
int n = sizeof(arr)/sizeof(arr[0]);
print(arr, n, r);
}
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 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 11
- Miscellaneous on Data Structures - Section 12