Question: ***NEED THE CODE IN C*** #include #include #define DIM 80 #define EMPTY -1 int max(int a, int b); /* Returns max(a,b) */ int strLength(char s[]);

***NEED THE CODE IN C***
#include#include #define DIM 80 #define EMPTY -1 int max(int a, int b); /* Returns max(a,b) */ int strLength(char s[]); /* Returns the length of a char string */ int ** createMemo(int numRow, int numCol); void destroyMemo(int ** memo, int numRow); int lcsRec(char str1[], char str2[] , int ** memo, int len1, int len2) { if (memo[len1][len2]==EMPTY) { if (len1==0 || len2==0) { memo[len1][len2]=0; } else if (str1[len1]==str2[len2]) { memo[len1][len2]=lcsRec(str1,str2,memo,len1-1,len2-1)+1; } else { int temp1=lcsRec(str1,str2,memo,len1-1,len2); int temp2=lcsRec(str1,str2,memo,len1,len2-1); memo[len1][len2]=max(temp1,temp2); } } return memo[len1][len2]; } int lcs(char str1[], char str2[]) { int len1 = strLength(str1); int len2 = strLength(str2); int ** memo = createMemo(len1,len2); for (int i=0; i b) return a; return b; } int strLength(char s[]) { int k=0; for(; s[k]!='\0'; k++); return k; }
Problem 2 ( 2 pts). Attached is a program Ics1.c which computes the longest common subsequence of two text strings. If you run it, the program will only give you the length of the longest common subsequence. Rewrite it so that the program will also output the longest common subsequence in addition to its length: String = ABCAABCCABCCBA Length =14 String = BABCCCBBACAA Length =12 LCS: ABCCCACA LCS length = 8 String = ABCBDAB Length =7 String = BDCABA Length =6 LCS: BCBA LCS length = 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
