McCrieght’s algorithm for linear- time suffix tree construction Example
Example string: AAAAAAA AAAAAAA$ root T0:T0: Conventions: T i corresponds to the tree after i iterations. Suffix numbering and string indexing starts from 1 and ends at n. Only for convenience in presentation, edge-labels are shown as strings. In the implementation, it is assumed that edge-labels are stored as a pair of integers. T1:T1: Initial tree: Denotes suffix links
Example string: AAAAAAA AAAAAAA$ root T0:T0: T1:T1: 1 A A A A A A A $ Tally of cost Number of character comparisons 0 Number of node hops0 Iteration: 1 For this iteration:
Example string: AAAAAAA AAAAAAA$ root T2:T2: 1 A A A A A A A $ Tally of cost Number of character comparisons 7 Number of node hops0 Iteration: 2 root T1:T1: 1 A A A A A A A $ Case IB 2 $ For this iteration:
Example string: AAAAAAA AAAAAAA$ root T3:T3: 1 A A A A A A A $ Tally of cost Number of character comparisons 1 Number of node hops1 Iteration: 3 Case IIB 2 $ root T2:T2: 1 A A A A A A A $ 2 $ =AAAAAA = A ’ 3 $ For this iteration:
Example string: AAAAAAA AAAAAAA$ root T4:T4: 1 A A A A A A A $ Tally of cost Number of character comparisons 1 Number of node hops1 Iteration: 4 Case IIB 2 $ root T3:T3: 1 A A A A A A A $ 2 $ =AAAAA = A ’ 3 $ 3 $ 4 $ For this iteration:
Example string: AAAAAAA AAAAAAA$ root T5:T5: 1 A A A A A A A $ Tally of cost Number of character comparisons 1 Number of node hops1 Iteration: 5 Case IIB 2 $ root T4:T4: 1 A A A A A A A $ 2 $ =AAAA = A ’ 3 $ 3 $ 4 $ 4 $ 5 $ For this iteration:
Example string: AAAAAAA AAAAAAA$ root T6:T6: 1 A A A A A A A $ Tally of cost Number of character comparisons 1 Number of node hops1 Iteration: 6 Case IIB 2 $ root T5:T5: 1 A A A A A A A $ 2 $ =AAA = A ’ 3 $ 3 $ 4 $ 4 $ 5 $ 5 $ 6 $ For this iteration:
Example string: AAAAAAA AAAAAAA$ root T7:T7: 1 A A A A A A A $ Tally of cost Number of character comparisons 1 Number of node hops1 Iteration: 7 Case IIB 2 $ root T6:T6: 1 A A A A A A A $ 2 $ =AA = A ’ 3 $ 3 $ 4 $ 4 $ 5 $ 5 $ 6 $ 6 $ 7 $ For this iteration:
Example string: AAAAAAA AAAAAAA$ root T8:T8: 1 A A A A A A A $ Tally of cost Number of character comparisons 0 Number of node hops0 Iteration: 8 Case IIB 2 $ root T7:T7: 1 A A A A A A A $ 2 $ =A = A ’ 3 $ 3 $ 4 $ 4 $ 5 $ 5 $ 6 $ 6 $ 7 $ 7 $ 8 $ TOTAL Tally of cost over all iterations Number of character comparisons 12 Number of node hops5 For this iteration: