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

20/59

Page

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

What is the time complexity of the following code used to convert a decimal number to its binary equivalent?
#include<stdio.h>
void dec_to_bin(int n)
{
      int arr[31],len = 0,i;
      if(n == 0)
      {
          arr[0] = 0;
          len = 1;
      }
      while(n != 0)
      {
          arr[len++] = n % 2;
          n /= 2;
      }
      for(i=len-1; i>=0; i--)
        printf("%d",arr[i]);
}
int main()
{
     int n = 0;
     dec_to_bin(n);
     return 0;
}

Select an option to see the answer and solution.

Which of the following is a disadvantage of quickselect?

Select an option to see the answer and solution.

What is the output of the following code?
#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[8] = {1,2,3,4,5,6,7,8},num = 7,len = 8;
      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.

How many approaches can be applied to solve quick hull problem?

Select an option to see the answer and solution.

A man wants to go different places in the world. He has listed them down all. But there are some places where he wants to visit before some other places. What application of graph can he use to determine that?

Select an option to see the answer and solution.

Dynamic programming approach can be used to implement Catalan numbers.

Select an option to see the answer and solution.

. . . . . . . . enumerates a list of promising nodes that could be computed to give the possible solutions of a given problem.

Select an option to see the answer and solution.

Which of the following forms a sequence of natural numbers that occur in different counting problems?

Select an option to see the answer and solution.

In the least recently used algorithm, if the current page doesn't exist in the set then it is replaced with the recently used page.

Select an option to see the answer and solution.

Consider the following iterative implementation to find the nth fibonacci number?
int main()
{
    int  n = 10,i;
    if(n == 1)
        printf("0");
    else if(n == 2)
        printf("1");
    else
    {
        int a = 0, b = 1, c;
        for(i = 3; i <= n; i++)
        {
            c = a + b;
            ________;
			________;
        }
        printf("%d",c);
    }
   return 0;
}
Which of the following lines should be added to complete the above code?

Options are not available for this question.

Select an option to see the answer and solution.

Which of the problems cannot be solved by backtracking method?

Select an option to see the answer and solution.

What is the magnitude of resultant of cross product of two parallel vectors a and b?

Select an option to see the answer and solution.

What will be the ciphered text corresponding to "EXAMPLE" if beaufort cipher is used for encryption with key as "PASS"?

Select an option to see the answer and solution.

. . . . . . . . states that, on a page fault, the frame that has been in memory the longest is replaced.

Select an option to see the answer and solution.

Which of the following recursive formula can be used to find the factorial of a number?

Select an option to see the answer and solution.

How many stages of procedure does a non-deterministic algorithm consist of?

Select an option to see the answer and solution.

Consider the given page reference string 3, 1, 0, 2, 1, 5, 6, 2, 8, 6, 9, 1. How many page faults will occur if the program has 4-page frames available to it and it uses the not recently used algorithm?

Select an option to see the answer and solution.

Poly alphabetic cipher harder to decipher than mono alphabetic cipher.

Select an option to see the answer and solution.

Solve the following recurrence using Master's theorem.
T(n) = 0.7 T (n/2) + 1/n

Select an option to see the answer and solution.

A two-out-of-five code consists of . . . . . . . .

Select an option to see the answer and solution.