Sail E0 Webinar

MCQs

Total Questions : 22 | Page 3 of 3 pages
Question 21. Consider the following dynamic programming implementation of the minimum jumps problem:#include#includeint min_jump(int *arr, int len){     int j, idx, jumps[len];     jumps[len - 1] = 0;     for(idx = len - 2; idx >= 0; idx--)     {   int tmp_min = INT_MAX;   for(j = 1; j
  1.    for(j = 1; j < arr[idx] + len; j++)
  2.    for(j = 0; j < arr[idx] "“ len; j++)
  3.    for(j = idx + 1; j < len && j
  4.    None of the mentioned
 Discuss Question
Answer: Option D. -> None of the mentioned


None of the above mentioned "for loops can be used instead of the inner for loop. Note, for(j = idx + 1; j < len && j

Question 22. Consider the following dynamic programming implementation:#include#includeint max(int a, int b){      if(a > b)        return a;      return b;}int min_ins(char *s){      int len = strlen(s), i, j;      int arr[len + 1][len + 1];      char rev[len + 1];      strcpy(rev, s);      strrev(rev);      for(i = 0;i
  1.    arr[len][len].
  2.    len + arr[len][len].
  3.    len
  4.    len "“ arr[len][len].
 Discuss Question
Answer: Option C. -> len


arr[len][len] contains the length of the longest palindromic subsequence. So, len “ arr[len][len] gives the minimum number of insertions required to form a palindrome.


Latest Videos

Latest Test Papers