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

22/59

Page

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

What will be the output for following code?
#include <stdio.h> 
#include <string.h> 
#include <iostream.h>
using namespace std;
void swap(char *x, char *y) 
{ 
	char temp; 
	temp = *x; 
	*x = *y; 
	*y = temp; 
} 
 
void func(char *a, int l, int r) 
{ 
int i; 
if (l == r) 
	cout<<a<<” ,”; 
else
{ 
	for (i = l; i <= r; i++) 
	{ 
		swap((a+l), (a+i)); 
		func(a, l+1, r); 
		swap((a+l), (a+i)); 
	} 
} 
} 
 
int main() 
{ 
	char str[] = "AB"; 
	int n = strlen(str); 
	func(str, 0, n-1); 
	return 0; 
}

Select an option to see the answer and solution.

Route cipher falls under the category of?

Select an option to see the answer and solution.

What is the time complexity of floyd's cycle finding algorithm?

Select an option to see the answer and solution.

In general, which of the following methods isn't used to find the factorial of a number?

Select an option to see the answer and solution.

The choice of polynomial class has led to the development of an extensive theory called . . . . . . . .

Select an option to see the answer and solution.

What is the average case time complexity of recursive selection sort?

Select an option to see the answer and solution.

What is the output of the following code?
int fibo(int n)
{ 
      if(n == 1)
        return 0;
      else if(n == 2)
        return 1;
      return fibo(n - 1) + fibo(n - 2);
}
int main()
{
     int n = 10;
     int ans = fibo(n);
     printf("%d",ans);
     return 0;
}

Select an option to see the answer and solution.

Fractional knapsack problem is solved most efficiently by which of the following algorithm?

Select an option to see the answer and solution.

As the number of frames available increases, the number of page faults decreases.

Select an option to see the answer and solution.

If 4 is the GCD of 16 and 12, What is the GCD of 12 and 4?

Select an option to see the answer and solution.

How many edges does a n vertex triangle free graph contains?

Select an option to see the answer and solution.

The worst-case efficiency of solving a problem in polynomial time is?

Select an option to see the answer and solution.

What is the output of the following code?
#include<stdio.h>
int max_of_two(int a, int b)
{
      if(a > b)
        return a;
      return b;
}
int min_of_two(int a, int b)
{
      if(a < b)
        return a;
      return b;
}
int recursive_max_element(int *arr, int len, int idx)
{
      if(idx == len - 1)
      return arr[idx];
      return max_of_two(arr[idx], recursive_max_element(arr, len, idx + 1));
}
int recursive_min_element(int *arr, int len, int idx)
{
      if(idx == len - 1)
      return arr[idx];
      return min_of_two(arr[idx], recursive_min_element(arr, len, idx + 1));
}
int main()
{
    int n = 10, idx = 0, arr[] = {5,2,6,7,8,9,3,-1,1,10};
    int max_element = recursive_max_element(arr,n,idx);
    int min_element = recursive_min_element(arr,n,idx);
    printf("%d %d",max_element,min_element);
    return 0;
}

Select an option to see the answer and solution.

What is the output of the following code?
#include<stdio.h>
int max_of_two(int a, int b)
{
      if(a > b)
        return a;
      return b;
}
int min_of_two(int a, int b)
{
      if(a < b)
        return a;
      return b;
}
int recursive_max_element(int *arr, int len, int idx)
{
      if(idx == len - 1)
      return arr[idx];
      return max_of_two(arr[idx], recursive_max_element(arr, len, idx + 1));
}
int recursive_min_element(int *arr, int len, int idx)
{
      if(idx == len - 1)
      return arr[idx];
      return min_of_two(arr[idx], recursive_min_element(arr, len, idx + 1));
}
int main()
{
     int n = 5, idx = 0, arr[] = {1,1,1,1,1};
     int max_element = recursive_max_element(arr,n,idx);
     int min_element = recursive_min_element(arr,n,idx);
     printf("%d %d",max_element,min_element);
     return 0;
}

Select an option to see the answer and solution.

What is the output of the following code?
#include<stdio.h>
int recursive_search_num(int *arr, int num, int idx, int len)
{
     if(idx == len)
      return -1;
     if(arr[idx] == num)
      return idx;
     return recursive_search_num(arr, num, idx+1, len);
}
int main()
{
      int arr[8] ={-11,2,-3,0,3,5,-6,7},num = -2,len = 8;
      int indx = recursive_search_num(arr,num,0,len);
      printf("Index of %d is %d",num,indx);
      return 0;
}

Select an option to see the answer and solution.

What will be the output of the code that generates permutations and also has the ability to handle duplicates, for the input str[]="AA"?

Select an option to see the answer and solution.

What will be the chromatic index for a complete graph having n vertices (consider n to be an odd number)?

Select an option to see the answer and solution.

Who invented Euclid's algorithm?

Select an option to see the answer and solution.

Gronsfeld cipher is a variation of . . . . . . . .

Select an option to see the answer and solution.

The no. of partitions of which of the following integer will be divisible by 5?

Select an option to see the answer and solution.