ExamVeda
Login
Home
71
Which of the following implementations of Catalan numbers has the smallest time complexity?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
72
The longest increasing subsequence problem is a problem to find the length of a subsequence from a sequence of array elements such that the subsequence is sorted in increasing order and it's length is maximum. This problem can be solved using . . . . . . . .
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
73
What is the space complexity of the following for loop method used to compute the nth fibonacci term?
int fibo(int n)
    if n == 0
       return 0 
    else
       prevFib = 0
       curFib = 1
       for i : 1 to n-1
           nextFib = prevFib + curFib
	   prevFib = curFib
           curFib = nextFib
       return curFib
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
74
The 0-1 Knapsack problem can be solved using Greedy algorithm.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
75
Consider a variation of the balanced partition problem in which we find two subsets such that |S1 - S2| is minimum. Consider the array {1, 2, 3, 4, 5}. Which of the following pairs of subsets is an optimal solution for the above problem?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
76
Consider the expression T | F ∧ T. In how many ways can the expression be parenthesized so that the output is F (false)?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
77
What is the output of the following code?
#include<stdio.h>
#include<string.h>
int get_min(int a, int b)
{
      if(a < b)
        return a;
      return b;
}
int edit_distance(char *s1, char *s2)
{
     int len1,len2,i,j,min;
     len1 = strlen(s1);
     len2 = strlen(s2);
     int arr[len1 + 1][len2 + 1];
     for(i = 0;i <= len1; i++)
      arr[i][0] = i;
     for(i = 0; i <= len2; i++)
      arr[0][i] = i;
     for(i = 1; i <= len1; i++)
     {
         for(j = 1; j <= len2; j++)
         {
              min = get_min(arr[i-1][j],arr[i][j-1]) + 1;
              if(s1[i - 1] == s2[j - 1])
              {
                  if(arr[i-1][j-1] < min)
                      min = arr[i-1][j-1];
              }
              else
              {
                  if(arr[i-1][j-1] + 1 < min)
                     min = arr[i-1][j-1] + 1;
              }
              arr[i][j] = min;
         }
     }
     return arr[len1][len2];
}
int main()
{
     char s1[] = "abcd", s2[] = "defg";
     int ans = edit_distance(s1, s2);
     printf("%d",ans);
     return 0;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
78
When dynamic programming is applied to a problem, it takes far less time as compared to other methods that don't take advantage of overlapping subproblems.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
79
Consider the string "efge". What is the minimum number of insertions required to make the string a palindrome?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
80
Consider the following statements and select which of the following statement are true.
Statement 1: The maximum sum rectangle can be 1X1 matrix containing the largest element If the matrix size is 1X1
Statement 2: The maximum sum rectangle can be 1X1 matrix containing the largest element If all the elements are zero
Statement 3: The maximum sum rectangle can be 1X1 matrix containing the largest element If all the elements are negative
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board