Here are tables $\SA$ and $\LCP$ of the Suffix array of $\sa{aacab}$: \[\begin{array}{cccl} r & \SA & \LCP \cr \hline 0 & 0 & 0 & \sa{aacab} \cr 1 & 3 & 1 & \sa{ab} \cr 2 & 1 & 1 & \sa{acab} \cr 3 & 4 & 0 & \sa{b} \cr 4 & 2 & 0 & \sa{cab} \end{array}\] Table $\SA$ stores the starting position of non-empty suffixes according to their rank $r$ in lexicographic order. Suffixes themselves are not part of the structure. Table $\LCP[r]$ gives the longest common prefix between rank-$r$ and rank-$(r-1)$ suffixes.
The pictures below illustrate three first steps of a possible Suffix tree construction for the example $\sa{aacab}$. The first picture is when suffixes $\sa{aacab}$, $\sa{ab}$ and $\sa{acab}$ have been treated. Labels of nodes are their word depth and labels of arcs are in the form $(i,j)$ (on the left) representing factors $x[i\dd j-1]$ (on the right) of the word $x$. Doubly circled nodes are terminal states and thick paths show last inserted suffixes.
Problem 47: Suffix Array to the Suffix Tree |
The goal of the problem is to transform the Suffix array of a word $x$ into its Suffix tree. Despite the fact that both data structures infer essentially the same types of indexing operations, some come more readily from the Suffix tree structure.
The interest in designing a linear-time algorithm to do it is interesting when the alphabet is linearly sortable. Indeed, with this hypothesis, there are many linear-time algorithms to build the Suffix array of a word, although there is mostly one method to build its Suffix tree in the same time. Moreover, techniques used for the former construction are way easier to develop.