Skip to content

Suffix Tree

A compressed trie of every suffix of a text, turning exact substring search into a root-path walk and occurrence reporting into a read of descendant suffix positions.

Version
v2 · 2026-11-14 · History
Domain-specific #
13653
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomains
String Algorithms, Data Structures → Computer Science & Software Engineering
Aliases
Compressed suffix trie

Core Idea

A suffix tree is a compressed trie of every suffix of one text. Shared suffix prefixes follow the same path; nonbranching stretches become edges labelled by substrings of the original text. Since every substring is a prefix of some suffix, finding an exact pattern becomes a root-path walk. Leaves below the matched path give the pattern's starting positions. A distinct terminal is a standard way to make each suffix end at its own leaf.

How would you explain it like I'm…

The Word-Endings Tree

Take a word like 'banana' and write down all its endings: 'banana,' 'anana,' 'nana,' 'ana,' 'na,' 'a.' A suffix tree puts all those endings into one branching tree, where endings that start the same way share the same branch until they split apart. Then, to check if a piece like 'nan' is in the word, you just follow the branches letter by letter.

Tree of All Endings

A suffix of a word is the part from some letter to the end. A suffix tree stores every suffix of a text in a branching tree: suffixes that begin with the same letters share a path from the top, and the path splits where they differ. Since every piece of a text is the start of some suffix, you can find whether a piece appears by walking down the tree one letter at a time. If you can finish the walk, the piece is there, and the ends below that point tell you every place it appears. To save space, long branches with no splits are squeezed into one step.

Compressed Tree of Suffixes

A suffix tree is a data structure that stores all suffixes of one text in a compressed tree. A suffix is the text from some position to the end, and every substring is the beginning of some suffix. In the tree, suffixes that share a beginning share a path from the root, branching where they differ, and each suffix's starting position is recorded at its endpoint. To check whether a pattern appears, you follow its characters from the root; if the walk completes, it's there, and the endpoints underneath list all its occurrences. Paths without branches are collapsed into single edges labeled by start and end positions in the original text, which keeps the tree's size proportional to the text length instead of its square.

 

A suffix tree is a path-compressed trie of all suffixes of a single text. Since every substring begins at some position, it is a prefix of the suffix starting there, so the tree supports substring queries: shared suffix prefixes are merged into common root paths, branches occur where suffixes diverge, and starting positions are recorded at endpoints. An exact query follows its characters from the root; completing the walk establishes a match, and the suffix endpoints in the subtree below give all occurrences. Compression is essential: a plain trie of n suffixes can store quadratically many characters, but collapsing each nonbranching path into a single edge labeled with a start/end interval of the text keeps total space O(n). In the standard explicit form, a unique terminal symbol ensures no suffix is a prefix of another, so each suffix ends at its own leaf, giving n leaves and fewer internal branching nodes. With suitable access to outgoing edges, a pattern of length m is located in O(m) time, plus O(z) to report z occurrences. Suffix links and linear-time construction algorithms are useful implementation tools but are not part of what makes a finished structure a suffix tree; the defining invariant is that it contains all suffixes of one text.

Scope of Application

Suffix trees index strings for repeated exact searches, repeat analysis, and related sequence tasks. The same structure can index a document or a DNA sequence; the meaning of the characters changes, not the suffix-index invariant. Fast lookup requires appropriate edge access, and reporting many matches still costs time proportional to the answer size.

Clarity

The structure turns an inside-the-text question into a prefix-of-a-stored-suffix question. It differs from a generic radix tree because it stores all suffixes of one text, and from a suffix array because it explicitly represents branching common prefixes. Suffix links can help build it efficiently but are not part of its defining identity.

Manages Complexity

Preprocessing overlapping suffixes into shared paths avoids rescanning the whole text for every later query. Path compression and interval-labelled edges reduce the standard explicit tree to linear space. Under suitable alphabet and edge-access assumptions, exact existence lookup takes time proportional to pattern length rather than text length.

Abstract Reasoning

To test an index, ask whether it represents every text suffix, merges their common prefixes, and compresses nonbranching paths. To search, compare the pattern against successive edge labels from the root. If all pattern characters match, the descendant suffix positions are exactly the occurrence starts; a mismatch excludes the pattern.

Knowledge Transfer

Document search and genome-sequence search reuse the same data structure literally, with different alphabets and interpretations. Broader ideas about preprocessing or hierarchical search may inspire analogies, but the name “suffix tree” requires the specific all-suffix, compressed-prefix representation. See the staged V2 for source locators, qualified complexity claims, and boundary cases.

Relationships to Other Abstractions

Local relationship map for Suffix TreeParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Suffix TreeDOMAINDomain-specific abstraction: Radix tree — is a kind ofRadix treeDOMAIN

Current abstraction Suffix Tree Domain-specific

Parents (1) — outgoing typed relations

  • Suffix Tree is a kind of Radix tree Domain-specific

    A suffix tree is a path-compressed trie specialized to the set of all suffixes of one text.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Suffix Tree sits in a moderately populated region (55th percentile for distinctiveness): it has near-neighbors but no dense thicket of look-alikes.

Family — Formal Sequences & Language Structure (19 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14