Home / MCQ Bank / Computer
Computer Dynamic Programming In Data Structures

Consider the following code: #include<stdio.h> #include<string.h> int max_num(int a, int b) { if(a > b) return a; return b; } int lps(char *str1) { int i,j,len; len = strlen(str1); char str2[len + 1]; strcpy(str2, str1); ______________; int arr[len + 1][len + 1]; for(i = 0; i <= len; i++) arr[i][0] = 0; for(i = 0; i <= len; i++) arr[0][i] = 0; for(i = 1; i <= len; i++) { for(j = 1; j <= len; j++) { if(str1[i-1] == str2[j - 1]) arr[i][j] = 1 + arr[i - 1][j - 1]; else arr[i][j] = max_num(arr[i - 1][j], arr[i][j - 1]); } } return arr[len][len]; } int main() { char str1[] = "ababcdabba"; int ans = lps(str1); printf("%d",ans); return 0; } Which of the following lines completes the above code?

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option A • strrev(str2)

Related Computer Questions

Each answer below shows example data from a table. Which answer is an example of the multivalue, multicolumn problem? Which of the following is valid body of split function? What will be the output of the following Python code snippet? print([i+j for i in "abc" for j in "def"]) Which of the following refers to a cursor type that when the cursor is opened, a primary key value is saved for each row in the recordset; when the application accesses a row, the key is used to fetch the current values of the row? What is the primary use of the keras package in R?