Search before asking
Motivation
In kvrocks LCS command, it uses Dynamic Programming. When two string S, T and get LCS(S, T),
- Time Complexity: O(|S||T|)
- Space Complexity: O(|S||T|)
When |S| and |T| is about 10000, it requires over 400MB.
Solution
We can reduce space complexity to O(|S|+|T|) using Hirschberg's algorithm, also it can recover LCS string.
Relevant paper: A Linear Space Algorithm for Computing Maximal Common Subsequences (Author: D.S. Hirschberg)
Are you willing to submit a PR?
Search before asking
Motivation
In kvrocks LCS command, it uses Dynamic Programming. When two string S, T and get LCS(S, T),
When |S| and |T| is about 10000, it requires over 400MB.
Solution
We can reduce space complexity to O(|S|+|T|) using Hirschberg's algorithm, also it can recover LCS string.
Relevant paper: A Linear Space Algorithm for Computing Maximal Common Subsequences (Author: D.S. Hirschberg)
Are you willing to submit a PR?