ExamVeda
Login
Home
81
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;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
82
Which of the following is a disadvantage of quickselect?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
83
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;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
84
How many approaches can be applied to solve quick hull problem?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
85
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?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
86
Dynamic programming approach can be used to implement Catalan numbers.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
87
. . . . . . . . enumerates a list of promising nodes that could be computed to give the possible solutions of a given problem.
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
88
Which of the following forms a sequence of natural numbers that occur in different counting problems?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
89
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.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
90
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?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board