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

11/59

Page

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

What is the output of the following code?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
     int n = -4;
     int ans = recursive_sum(n);
     printf("%d",ans);
     return 0;
}

Select an option to see the answer and solution.

Consider the fleury's algorithm given below. Which of the following best suits the blank?
Graph must have 0 or 2 odd vertices  
if there are 0 odd vertices, start from any vertex 
if there are 2 odd vertices, start from any one of them 
follow any of the edge, always choose the ______________  
repeat for all the edges of the graph

Select an option to see the answer and solution.

Vertex coloring and chromatic number are one and the same.

Select an option to see the answer and solution.

What is the output of the following code?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
     int n = 0;
     int ans = recursive_sum(n);
     printf("%d",ans);
     return 0;
}

Select an option to see the answer and solution.

Which algorithm can be used to find an eulerian cycle in a graph?

Select an option to see the answer and solution.

What is the time complexity of Heap's algorithm?

Select an option to see the answer and solution.

What will be the plain text corresponding to cipher text "RSEADC" if with the number of columns are given to be 3 and route of reading is down the columns?

Select an option to see the answer and solution.

What will be the encrypted text corresponding to plain text "EXAMPLE" using columnar transposition cipher with the keyword as "INDIA"?

Select an option to see the answer and solution.

What will be the slope of the line given by 10x + 5y + 8=0?

Select an option to see the answer and solution.

How many partitions will be formed for the integer 3?

Select an option to see the answer and solution.

Which cipher is represented by the following function?
public class Cipher
{
    public static String encrypt(String text, final String key)
    {
        String res = "";
        text = text.toUpperCase();
        for (int i = 0, j = 0; i < text.length(); i++)
        {
            char c = text.charAt(i);
            if (c < 'A' || c > 'Z')
                continue;
            res += (char) ((c + key.charAt(j) - 2 * 'A') % 26 + 'A');
            j = ++j % key.length();
        }
        return res;
    }

Select an option to see the answer and solution.

How many times is the function recursive_binary_search() called when the following code is executed?
#include<stdio.h>
int recursive_binary_search(int *arr, int num, int lo, int hi)
{
      if(lo > hi)
       return -1;
      int mid = (lo + hi)/2;
      if(arr[mid] == num)
        return mid;
      else if(arr[mid] < num)
          lo = mid + 1;
      else
          hi = mid - 1;
      return recursive_binary_search(arr, num, lo, hi);
}
int main()
{
      int arr[5] = {1,2,3,4,5},num = 1,len = 5;
      int indx = recursive_binary_search(arr,num,0,len-1);
      printf("Index of %d is %d",num,indx);
      return 0;
}

Select an option to see the answer and solution.

What is the period in bifid cipher?

Select an option to see the answer and solution.

An optimal solution satisfying men's preferences is said to be?

Select an option to see the answer and solution.

Which is the correct term of the given relation, lcm (a, b) * gcd (a, b) =?

Select an option to see the answer and solution.

The cost required to execute a FIFO algorithm is expensive.

Select an option to see the answer and solution.

The problem of placing n queens in a chessboard such that no two queens attack each other is called as?

Select an option to see the answer and solution.

What is the time complexity of the following recursive implementation used to find the largest and the smallest element in an array?
#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 formula used for decoding the ciphered text using affine cipher(a,b are constants and x is the numerical equivalent of a letter to be encrypted)?

Select an option to see the answer and solution.

What is the time complexity of the following recursive implementation to find the nth fibonacci number?
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 = 5;
     int ans = fibo(n);
     printf("%d",ans);
     return 0;
}

Select an option to see the answer and solution.