Implement the longest common subsequence (LCS) algorithm using the dynamic programming…
- User
Implement the longest common subsequence (LCS) algorithm using the dynamic programming method. Do not implement a brute force algorithm, which does exhaustive comparisons between two input strings, or any other algorithm. Name the file as lcs.java.
Make sure that program can take any two input strings in the Linux command line and print the LCS found between the two input strings. Assume that a string consists of at most 100 alphabetic characters.
For example, if we type “lcs abc afgbhcd” in the command line to find the LCS between string “abc” and string “afgbhcd”. Again, your program should work for arbitrary two input strings.Your program should work to find LCS for all for strings.
If input is more than 2 strings,it will return -1 and print "error" and if string1 or string2 is longer than 100 characters,it will return -2 and print "the string length too long". If the two strings are appropriate,the result will give the LCS and its length
Program Usage: Your program should be invoked as follows. $> ./lcs
A sample run of your program appears below. $> ./lcs ABCDEfghi AcbDedghaq A sample output is as follows (standard output in the terminal) Length of LCS: 4 LCS: ADgh
- Assistant