Back to Dashboard
Ukkonen's Suffix Tree
A compressed trie of all suffixes of a string, built in linear time using Ukkonen's algorithm — a cornerstone of modern string processing.
Input7/15
b
a
n
a
n
a
$
Loading…
FastSlow
Step 1 / 0
Time Complexity
Best
O(n)
Average
O(n)
Worst
O(n)
Space Complexity
O(n)
StabilityFALSE
In-placeFALSE
Explanation
A suffix tree is a compressed trie containing all the suffixes of the given text. Using Ukkonen's O(n) algorithm, it can be built efficiently, enabling fast substring search and pattern matching.
Pseudo Code
1function Ukkonen(S):2 activeNode = root3 activeEdge = -14 activeLen = 05 remainder = 067 for i = 0 to |S|-1:8 remainder++9 while remainder > 0:10 if no activeEdge:11 activeEdge = i12 if edge[activeNode][S[activeEdge]] missing:13 add new leaf (Rule 2a)14 else if S[activeLen on edge] == S[i]:15 activeLen++ // Rule 3 (stop)16 break17 else:18 split edge (Rule 2b)19 follow suffixLink
Sponsor Ad