You are on page 1of 8

SUFFIX TREE

Muhammad Atif Saeed 17-ARID-1876


Sadaf Khalid 17-ARID-1890
WHAT IS SUFFIX TREE
Suffix tree is a compressed trie of all the suffixes of a given string. Suffix
trees help in solving a lot of string related problems like pattern
matching, finding distinct substrings in a given string, finding longest
palindrome etc. In this tutorial following points will be covered:

• Suffix Trie
• Compressed Trie
• Suffix Tree Construction (Brute Force)
Application of the Suffix Tree
• Pattern Searching
• Finding the Longest Repeated Substring
• Finding the Longest Palindrome in a String
• Lowest Common Ancestors
• Finding the Longest Common Substring
• Exact String Matching
Suffix Tree | Standard Trie
• Bear
• Bell
• bid
• Bull
• Buy
• Sell
• Stock
• Stop
Suffix Tree | Compressed Trie
How to build a Suffix Tree for a given text?
• Suffix Tree is compressed trie of all suffixes, following are the Key
Steps.
• Generate all suffixes of given text.
1. Consider all suffixes as individual words and build a compressed trie.
• Let us consider an example text “banana\0” where ‘\0’ is string
termination character. Following are all suffixes of “banana\0”
• banana\0 • na\0
• anana\0 • a\0
• nana\0 • \0
• ana\0
Trie Suffix
Tree
of the above
Example:
Compressed Trie of the Suffix Tree

You might also like