-
Notifications
You must be signed in to change notification settings - Fork 608
Open
Labels
enhancementtype enhancementtype enhancement
Description
Search before asking
- I had searched in the issues and found no similar issues.
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?
- I'm willing to submit a PR!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementtype enhancementtype enhancement