Solution: Shortest Common Supersequence(SCS)
This review provides a detailed analysis of the different ways to solve the shortest common supersequence problem.
We'll cover the following...
We'll cover the following...
Solution 1: brute force
Explanation
In this solution, we try all the superstrings–one character at a time.
- If the sequences have a matching ith character, skip one character from both the sequences and make a recursive call for the remaining lengths (line 16 - line 17)
- If the characters don’t match, call the function recursively twice by skipping one character from each string (line 19 - line 20)
- Return the minimum result of these two calls (line 22)
Time complexity
The time complexity of the above algorithm is exponential , where n and m are ...