Phase 1

Scan the String and partition Suffixes based on the first prefixlen symbols of each suffix

Phase 2

Do for each partition:

1

START BuildSuffixTree

2

Populate Suffixes from current partition

3

Sort Suffixes on first symbol using Temp

4

Output branching and leaf nodes to the Tree

5

Push the nodes pointing to an unevaluated range onto the Stack

While Stack is not empty

6

Pop a node

7

Find the Longest Common Prefix (LCP) of all the suffixes in this range by checking the String

8

9

10

Sort the range in Suffixes on the first symbol using Temp

Write out branching nodes or leaf nodes to Tree

Push the nodes pointing to an unevaluated range onto the Stack

11

END