Input7/15
b
a
n
a
n
a
$
Loading…
FastSlow
Step 1 / 0
計算量(時間)
最良時
O(n)
平均時
O(n)
最悪時
O(n)
計算量(空間)
O(n)
StabilityFALSE
In-placeFALSE
解説
文字列のすべての接尾辞(サフィックス)を表す木構造です。O(n)で構築可能なUkkonenのアルゴリズムを用いることで、高速な文字列検索や部分一致検索などを可能にします。
疑似コード
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
スポンサー広告