Overview
Kasai's algorithm builds inverse suffix-array ranks and reuses the previous longest-common-prefix length, decreasing it by one before extending the next comparison.
Computes the LCP array from a suffix array in linear time.
Compact metadata for implementation and discovery.
Kasai's algorithm builds inverse suffix-array ranks and reuses the previous longest-common-prefix length, decreasing it by one before extending the next comparison.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n + m)
Worst
O(n + m)
Space
O(n + m)
h = max(h - 1, 0) before extending next suffix pairReuses all but one character of the previous longest common prefix.
Show reusing previous prefix length while scanning suffix ranks on a small longest common prefix array example.
Kasai's algorithm assumes the suffix array is already correct; it only builds the adjacent LCP array.
What each reference supports for this entry.
String algorithms reference for Kasai LCP Algorithm's pattern matching, suffix indexing, alignment, or sequence-processing mechanism.
Open sourceTextbook support for Kasai LCP Algorithm's algorithm family, complexity framing, and standard implementation concepts.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Pattern Matching · Core
Both address longest common prefix array, but they make different modeling or performance tradeoffs.
Compare with thisBoth address longest common prefix array, but they make different modeling or performance tradeoffs.
Both address longest common prefix array, but they make different modeling or performance tradeoffs.
Both address longest common prefix array, but they make different modeling or performance tradeoffs.