Sail E0 Webinar
Question
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
Options:
A .  arr[len][len].
B .  len + arr[len][len].
C .  len
D .  len "“ arr[len][len].
Answer: Option C


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.



Was this answer helpful ?

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers