Suffix Trees

Total Page:16

File Type:pdf, Size:1020Kb

Suffix Trees Suffix Trees Outline for Today ● Review from Last Time ● A quick refresher on tries. ● Suffix Tries ● A simple data structure for string searching. ● Suffix Trees ● A compact, powerful, and flexible data structure for string algorithms. ● Generalized Suffix Trees ● An even more flexible data structure. Review from Last Time A D B C B D A E A I O A R D T N T K U G D N A E D T T E I I A O K T Tries ● A trie is a tree that stores a collection of strings over some alphabet Σ. ● Each node corresponds to a prefix of some string in the set. ● Tries are sometimes called “prefix trees.” ● If |Σ| = O(1), all insertions, deletions, and lookups take time O(|w|), where w is the string in question. ● Can also determine whether a string w is a prefix of some string in the trie in time O(|w|) by walking the trie and returning whether we didn't fall off. Aho-Corasick String Matching ● The Aho-Corasick string matching algorithm is an algorithm for finding all occurrences of a set of strings P₁, …, Pₖ inside a string T. ● Runtime is O(m + n + z), where ● m = |T|, ● n = |P₁| + … + |Pₖ| ● z is the number of matches. Aho-Corasick String Matching ● The runtime of Aho-Corasick can be split apart into two pieces: ● O(n) preprocessing time to build the matcher, and ● O(m + z) time to find all matches. ● Useful in the case where the patterns are fixed, but the text might change. Genomics Databases ● Many string algorithms these days pertain to computational genomics. ● Typically, have a huge database with many very large strings. ● More common problem: given a fixed string T to search and changing patterns P₁, …, Pₖ, find all matches in T. ● Question: Can we instead preprocess T to make it easy to search for variable patterns? Suffix Tries Substrings, Prefixes, and Suffixes ● Recall: If x is a substring of w, then x is a suffix of a prefix of w. ● Write w = αxω; then x is a suffix of αx. ● Fact: If x is a substring of w, then x is a prefix of a suffix of w. ● Write w = αxω; then x is a prefix of xω ● This second fact is of use because tries support efficient prefix searching. Suffix Tries e s ● A suffix trie of T is a trie n o of all the suffices of T. n o s n e ● In time O(n), can determine whether P₁, …, s n e s n Pₖ exist in T by searching e s n e s for each one in the trie. e s n e n e s s e e nonsense A Typical Transform $ s n ● Typically, we e o append some new $ n o s n e character $ ∉ Σ to the end of T, then s n e s $ n construct the trie e s $ n e s for T$. $ e s n e ● Leaf nodes correspond to n e s $ suffixes. s $ e ● Internal nodes correspond to e $ prefixes of those suffixes. $ nonsense$ Constructing Suffix Tries ● Once we build a single suffix trie for string T, we can efficiently detect whether patterns match in time O(n). ● Question: How long does it take to construct a suffix trie? ● Problem: There's an Ω(m2) lower bound on the worst-case complexity of any algorithm for building suffix tries. A Degenerate Case $ a b $ a b b … b b … a $ ambm$ b b … b b b … b $ b … b $ ThereThere are are Θ( Θ(mm)) … b $ copiescopies of of nodes nodes chainedchained together together as as b $ m bbm$$.. $ 2 SpaceSpace usage: usage: Ω( Ω(mm2).). Correcting the Problem ● Because suffix tries may have Ω(m2) nodes, all suffix trie algorithms must run in time Ω(m2) in the worst-case. ● Can we reduce the number of nodes in the trie? Patricia Tries $ s n ● A “silly” node in a e o trie is a node that $ n o s n e has exactly one child. s n e s $ n ● A Patricia trie (or e s $ n e s radix trie) is a trie where all “silly” $ e s n e nodes are merged n e s $ with their parents. s $ e e $ $ nonsense$ Patricia Tries ● A “silly” node in a $ e s trie is a node that n o e has exactly one n $ n o s s $ child. e n s n e s ● A Patricia trie (or e s n s e radix trie) is a trie $ e $ n $ n e where all “silly” s $ s e nodes are merged e $ with their parents. $ nonsense$ 012345678 Suffix Trees ● A suffix tree for $ e s a string T is an n o e Patricia trie of T$ n 8 $ n o s s $ where each leaf is e n s n e s labeled with the 7 e s n s 6 e index where the $ e $ n $ n e corresponding s $ 4 s 5 e suffix starts in T$. e $ 3 $ 1 2 0 nonsense$ 012345678 Properties of Suffix Trees ● If |T| = m, the $ e s suffix tree has n o e exactly m + 1 n 8 $ n o s s $ leaf nodes. e n s n e s 7 e s n ● For any T ≠ ε, all s 6 e $ e $ n $ internal nodes in n e s $ the suffix tree 4 s 5 e e $ 3 have at least two $ 1 children. 2 ● Number of nodes 0 in a suffix tree is nonsense$ 012345678 Θ( m). Suffix Tree Representations ● Suffix trees may have Θ(m) nodes, but the labels on the edges can have size ω(1). ● This means that a naïve representation of a suffix tree may take ω(m) space. ● Useful fact: Each edge in a suffix tree is labeled with a consecutive range of characters from w. ● Trick: Represent each edge label α as a pair of integers [start, end] representing where in the string α appears. Suffix Tree Representations $ e s n o e n $ s 8 n o s $ n s n e e n s 7 e s 6 e $ e n o s $ e $ s n e $ start 8 4 0 1 3 n s s $ end 4 5 e 8 4 0 8 4 e $ 3 child $ 1 2 0 nonsense$ 012345678 Building Suffix Trees ● Using this representation, suffix trees can be constructed using space Θ(m). ● Claim: There are Θ(m)-time algorithms for building suffix trees. ● These algorithms are not trivial. We'll discuss one of them next time. An Application: String Matching String Matching ● Given a suffix tree, $ e s can search to see if n o e a pattern P exists in n 8 $ n o s s $ time O(n). e n s n e s ● Gives an O(m + n) 7 e s n s 6 e string-matching $ e $ n $ n e algorithm. s $ s e 4 e 5 3 ● T can be $ $ 1 preprocessed in time O(m) to 2 0 efficiently support binary string nonsense$ matching queries. 012345678 String Matching ● Claim: After $ e s spending O(m) time n o e preprocessing T$, n $ s can find all 8 n o s $ n s e e matches of a string n s 7 e s n P in time O(n + z), s 6 e $ e $ n $ where z is the n e s $ number of matches. 4 s 5 e e $ 3 $ 1 2 0 nonsense$ 012345678 String Matching ● Claim: After $ e s spending O(m) time n o e preprocessing T$, n $ s can find all 8 n o s $ n s e e matches of a string n s 7 e s n P in time O(n + z), s 6 e $ e $ n $ where z is the n e s $ number of matches. 4 s 5 e e $ 3 $ 1 Observation 1: Every Observation 1: Every 2 occurrenceoccurrence of of P P in in T T is is a a 0 prefixprefix of of some some suffix suffix of of T T.. nonsense$ 012345678 String Matching ● Claim: After $ e s spending O(m) time n o e preprocessing T$, n $ s can find all 8 n o s $ n s e e matches of a string n s 7 e s n P in time O(n + z), s 6 e $ e $ n $ where z is the n e s $ number of matches. 4 s 5 e e $ 3 $ 1 Observation 2: Because Observation 2: Because 2 thethe prefix prefix is is the the same same 0 eacheach time time (namely, (namely, P P),), all all thosethose suffixes suffixes will will be be in in nonsense$ thethe same same subtree. subtree. 012345678 String Matching ● Claim: After $ e s spending O(m) time n o e preprocessing T$, n $ s can find all 8 n o s $ n s e e matches of a string n s 7 e s n P in time O(n + z), s 6 e $ e $ n $ where z is the n e s $ number of matches. 4 s 5 e e $ 3 $ 1 2 0 nonsense$ 012345678 String Matching ● Claim: After $ e s spending O(m) time n o e preprocessing T$, n $ s can find all 8 n o s $ n s e e matches of a string n s 7 e s n P in time O(n + z), s 6 e $ e $ n $ where z is the n e s $ number of matches.
Recommended publications
  • Application of TRIE Data Structure and Corresponding Associative Algorithms for Process Optimization in GRID Environment
    Application of TRIE data structure and corresponding associative algorithms for process optimization in GRID environment V. V. Kashanskya, I. L. Kaftannikovb South Ural State University (National Research University), 76, Lenin prospekt, Chelyabinsk, 454080, Russia E-mail: a [email protected], b [email protected] Growing interest around different BOINC powered projects made volunteer GRID model widely used last years, arranging lots of computational resources in different environments. There are many revealed problems of Big Data and horizontally scalable multiuser systems. This paper provides an analysis of TRIE data structure and possibilities of its application in contemporary volunteer GRID networks, including routing (L3 OSI) and spe- cialized key-value storage engine (L7 OSI). The main goal is to show how TRIE mechanisms can influence de- livery process of the corresponding GRID environment resources and services at different layers of networking abstraction. The relevance of the optimization topic is ensured by the fact that with increasing data flow intensi- ty, the latency of the various linear algorithm based subsystems as well increases. This leads to the general ef- fects, such as unacceptably high transmission time and processing instability. Logically paper can be divided into three parts with summary. The first part provides definition of TRIE and asymptotic estimates of corresponding algorithms (searching, deletion, insertion). The second part is devoted to the problem of routing time reduction by applying TRIE data structure. In particular, we analyze Cisco IOS switching services based on Bitwise TRIE and 256 way TRIE data structures. The third part contains general BOINC architecture review and recommenda- tions for highly-loaded projects.
    [Show full text]
  • Compressed Suffix Trees with Full Functionality
    Compressed Suffix Trees with Full Functionality Kunihiko Sadakane Department of Computer Science and Communication Engineering, Kyushu University Hakozaki 6-10-1, Higashi-ku, Fukuoka 812-8581, Japan [email protected] Abstract We introduce new data structures for compressed suffix trees whose size are linear in the text size. The size is measured in bits; thus they occupy only O(n log |A|) bits for a text of length n on an alphabet A. This is a remarkable improvement on current suffix trees which require O(n log n) bits. Though some components of suffix trees have been compressed, there is no linear-size data structure for suffix trees with full functionality such as computing suffix links, string-depths and lowest common ancestors. The data structure proposed in this paper is the first one that has linear size and supports all operations efficiently. Any algorithm running on a suffix tree can also be executed on our compressed suffix trees with a slight slowdown of a factor of polylog(n). 1 Introduction Suffix trees are basic data structures for string algorithms [13]. A pattern can be found in time proportional to the pattern length from a text by constructing the suffix tree of the text in advance. The suffix tree can also be used for more complicated problems, for example finding the longest repeated substring in linear time. Many efficient string algorithms are based on the use of suffix trees because this does not increase the asymptotic time complexity. A suffix tree of a string can be constructed in linear time in the string length [28, 21, 27, 5].
    [Show full text]
  • KP-Trie Algorithm for Update and Search Operations
    The International Arab Journal of Information Technology, Vol. 13, No. 6, November 2016 722 KP-Trie Algorithm for Update and Search Operations Feras Hanandeh1, Izzat Alsmadi2, Mohammed Akour3, and Essam Al Daoud4 1Department of Computer Information Systems, Hashemite University, Jordan 2, 3Department of Computer Information Systems, Yarmouk University, Jordan 4Computer Science Department, Zarqa University, Jordan Abstract: Radix-Tree is a space optimized data structure that performs data compression by means of cluster nodes that share the same branch. Each node with only one child is merged with its child and is considered as space optimized. Nevertheless, it can’t be considered as speed optimized because the root is associated with the empty string. Moreover, values are not normally associated with every node; they are associated only with leaves and some inner nodes that correspond to keys of interest. Therefore, it takes time in moving bit by bit to reach the desired word. In this paper we propose the KP-Trie which is consider as speed and space optimized data structure that is resulted from both horizontal and vertical compression. Keywords: Trie, radix tree, data structure, branch factor, indexing, tree structure, information retrieval. Received January 14, 2015; accepted March 23, 2015; Published online December 23, 2015 1. Introduction the exception of leaf nodes, nodes in the trie work merely as pointers to words. Data structures are a specialized format for efficient A trie, also called digital tree, is an ordered multi- organizing, retrieving, saving and storing data. It’s way tree data structure that is useful to store an efficient with large amount of data such as: Large data associative array where the keys are usually strings, bases.
    [Show full text]
  • Lecture 26 Fall 2019 Instructors: B&S Administrative Details
    CSCI 136 Data Structures & Advanced Programming Lecture 26 Fall 2019 Instructors: B&S Administrative Details • Lab 9: Super Lexicon is online • Partners are permitted this week! • Please fill out the form by tonight at midnight • Lab 6 back 2 2 Today • Lab 9 • Efficient Binary search trees (Ch 14) • AVL Trees • Height is O(log n), so all operations are O(log n) • Red-Black Trees • Different height-balancing idea: height is O(log n) • All operations are O(log n) 3 2 Implementing the Lexicon as a trie There are several different data structures you could use to implement a lexicon— a sorted array, a linked list, a binary search tree, a hashtable, and many others. Each of these offers tradeoffs between the speed of word and prefix lookup, amount of memory required to store the data structure, the ease of writing and debugging the code, performance of add/remove, and so on. The implementation we will use is a special kind of tree called a trie (pronounced "try"), designed for just this purpose. A trie is a letter-tree that efficiently stores strings. A node in a trie represents a letter. A path through the trie traces out a sequence ofLab letters that9 represent : Lexicon a prefix or word in the lexicon. Instead of just two children as in a binary tree, each trie node has potentially 26 child pointers (one for each letter of the alphabet). Whereas searching a binary search tree eliminates half the words with a left or right turn, a search in a trie follows the child pointer for the next letter, which narrows the search• Goal: to just words Build starting a datawith that structure letter.
    [Show full text]
  • Suffix Trees
    JASS 2008 Trees - the ubiquitous structure in computer science and mathematics Suffix Trees Caroline L¨obhard St. Petersburg, 9.3. - 19.3. 2008 1 Contents 1 Introduction to Suffix Trees 3 1.1 Basics . 3 1.2 Getting a first feeling for the nice structure of suffix trees . 4 1.3 A historical overview of algorithms . 5 2 Ukkonen’s on-line space-economic linear-time algorithm 6 2.1 High-level description . 6 2.2 Using suffix links . 7 2.3 Edge-label compression and the skip/count trick . 8 2.4 Two more observations . 9 3 Generalised Suffix Trees 9 4 Applications of Suffix Trees 10 References 12 2 1 Introduction to Suffix Trees A suffix tree is a tree-like data-structure for strings, which affords fast algorithms to find all occurrences of substrings. A given String S is preprocessed in O(|S|) time. Afterwards, for any other string P , one can decide in O(|P |) time, whether P can be found in S and denounce all its exact positions in S. This linear worst case time bound depending only on the length of the (shorter) string |P | is special and important for suffix trees since an amount of applications of string processing has to deal with large strings S. 1.1 Basics In this paper, we will denote the fixed alphabet with Σ, single characters with lower-case letters x, y, ..., strings over Σ with upper-case or Greek letters P, S, ..., α, σ, τ, ..., Trees with script letters T , ... and inner nodes of trees (that is, all nodes despite of root and leaves) with lower-case letters u, v, ...
    [Show full text]
  • Full-Text and Keyword Indexes for String Searching
    Technische Universität München Full-text and Keyword Indexes for String Searching by Aleksander Cisłak arXiv:1508.06610v1 [cs.DS] 26 Aug 2015 Master’s Thesis in Informatics Department of Informatics Technische Universität München Full-text and Keyword Indexes for String Searching Indizierung von Volltexten und Keywords für Textsuche Author: Aleksander Cisłak ([email protected]) Supervisor: prof. Burkhard Rost Advisors: prof. Szymon Grabowski; Tatyana Goldberg, MSc Master’s Thesis in Informatics Department of Informatics August 2015 Declaration of Authorship I, Aleksander Cisłak, confirm that this master’s thesis is my own work and I have docu- mented all sources and material used. Signed: Date: ii Abstract String searching consists in locating a substring in a longer text, and two strings can be approximately equal (various similarity measures such as the Hamming distance exist). Strings can be defined very broadly, and they usually contain natural language and biological data (DNA, proteins), but they can also represent other kinds of data such as music or images. One solution to string searching is to use online algorithms which do not preprocess the input text, however, this is often infeasible due to the massive sizes of modern data sets. Alternatively, one can build an index, i.e. a data structure which aims to speed up string matching queries. The indexes are divided into full-text ones which operate on the whole input text and can answer arbitrary queries and keyword indexes which store a dictionary of individual words. In this work, we present a literature review for both index categories as well as our contributions (which are mostly practice-oriented).
    [Show full text]
  • Efficient In-Memory Indexing with Generalized Prefix Trees
    Efficient In-Memory Indexing with Generalized Prefix Trees Matthias Boehm, Benjamin Schlegel, Peter Benjamin Volk, Ulrike Fischer, Dirk Habich, Wolfgang Lehner TU Dresden; Database Technology Group; Dresden, Germany Abstract: Efficient data structures for in-memory indexing gain in importance due to (1) the exponentially increasing amount of data, (2) the growing main-memory capac- ity, and (3) the gap between main-memory and CPU speed. In consequence, there are high performance demands for in-memory data structures. Such index structures are used—with minor changes—as primary or secondary indices in almost every DBMS. Typically, tree-based or hash-based structures are used, while structures based on prefix-trees (tries) are neglected in this context. For tree-based and hash-based struc- tures, the major disadvantages are inherently caused by the need for reorganization and key comparisons. In contrast, the major disadvantage of trie-based structures in terms of high memory consumption (created and accessed nodes) could be improved. In this paper, we argue for reconsidering prefix trees as in-memory index structures and we present the generalized trie, which is a prefix tree with variable prefix length for indexing arbitrary data types of fixed or variable length. The variable prefix length enables the adjustment of the trie height and its memory consumption. Further, we introduce concepts for reducing the number of created and accessed trie levels. This trie is order-preserving and has deterministic trie paths for keys, and hence, it does not require any dynamic reorganization or key comparisons. Finally, the generalized trie yields improvements compared to existing in-memory index structures, especially for skewed data.
    [Show full text]
  • Search Trees
    Lecture III Page 1 “Trees are the earth’s endless effort to speak to the listening heaven.” – Rabindranath Tagore, Fireflies, 1928 Alice was walking beside the White Knight in Looking Glass Land. ”You are sad.” the Knight said in an anxious tone: ”let me sing you a song to comfort you.” ”Is it very long?” Alice asked, for she had heard a good deal of poetry that day. ”It’s long.” said the Knight, ”but it’s very, very beautiful. Everybody that hears me sing it - either it brings tears to their eyes, or else -” ”Or else what?” said Alice, for the Knight had made a sudden pause. ”Or else it doesn’t, you know. The name of the song is called ’Haddocks’ Eyes.’” ”Oh, that’s the name of the song, is it?” Alice said, trying to feel interested. ”No, you don’t understand,” the Knight said, looking a little vexed. ”That’s what the name is called. The name really is ’The Aged, Aged Man.’” ”Then I ought to have said ’That’s what the song is called’?” Alice corrected herself. ”No you oughtn’t: that’s another thing. The song is called ’Ways and Means’ but that’s only what it’s called, you know!” ”Well, what is the song then?” said Alice, who was by this time completely bewildered. ”I was coming to that,” the Knight said. ”The song really is ’A-sitting On a Gate’: and the tune’s my own invention.” So saying, he stopped his horse and let the reins fall on its neck: then slowly beating time with one hand, and with a faint smile lighting up his gentle, foolish face, he began..
    [Show full text]
  • Lecture 1: Introduction
    Lecture 1: Introduction Agenda: • Welcome to CS 238 — Algorithmic Techniques in Computational Biology • Official course information • Course description • Announcements • Basic concepts in molecular biology 1 Lecture 1: Introduction Official course information • Grading weights: – 50% assignments (3-4) – 50% participation, presentation, and course report. • Text and reference books: – T. Jiang, Y. Xu and M. Zhang (co-eds), Current Topics in Computational Biology, MIT Press, 2002. (co-published by Tsinghua University Press in China) – D. Gusfield, Algorithms for Strings, Trees, and Sequences: Computer Science and Computational Biology, Cambridge Press, 1997. – D. Krane and M. Raymer, Fundamental Concepts of Bioin- formatics, Benjamin Cummings, 2003. – P. Pevzner, Computational Molecular Biology: An Algo- rithmic Approach, 2000, the MIT Press. – M. Waterman, Introduction to Computational Biology: Maps, Sequences and Genomes, Chapman and Hall, 1995. – These notes (typeset by Guohui Lin and Tao Jiang). • Instructor: Tao Jiang – Surge Building 330, x82991, [email protected] – Office hours: Tuesday & Thursday 3-4pm 2 Lecture 1: Introduction Course overview • Topics covered: – Biological background introduction – My research topics – Sequence homology search and comparison – Sequence structural comparison – string matching algorithms and suffix tree – Genome rearrangement – Protein structure and function prediction – Phylogenetic reconstruction * DNA sequencing, sequence assembly * Physical/restriction mapping * Prediction of regulatiory elements • Announcements:
    [Show full text]
  • Search Trees for Strings a Balanced Binary Search Tree Is a Powerful Data Structure That Stores a Set of Objects and Supports Many Operations Including
    Search Trees for Strings A balanced binary search tree is a powerful data structure that stores a set of objects and supports many operations including: Insert and Delete. Lookup: Find if a given object is in the set, and if it is, possibly return some data associated with the object. Range query: Find all objects in a given range. The time complexity of the operations for a set of size n is O(log n) (plus the size of the result) assuming constant time comparisons. There are also alternative data structures, particularly if we do not need to support all operations: • A hash table supports operations in constant time but does not support range queries. • An ordered array is simpler, faster and more space efficient in practice, but does not support insertions and deletions. A data structure is called dynamic if it supports insertions and deletions and static if not. 107 When the objects are strings, operations slow down: • Comparison are slower. For example, the average case time complexity is O(log n logσ n) for operations in a binary search tree storing a random set of strings. • Computing a hash function is slower too. For a string set R, there are also new types of queries: Lcp query: What is the length of the longest prefix of the query string S that is also a prefix of some string in R. Prefix query: Find all strings in R that have S as a prefix. The prefix query is a special type of range query. 108 Trie A trie is a rooted tree with the following properties: • Edges are labelled with symbols from an alphabet Σ.
    [Show full text]
  • Suffix Trees for Fast Sensor Data Forwarding
    Suffix Trees for Fast Sensor Data Forwarding Jui-Chieh Wub Hsueh-I Lubc Polly Huangac Department of Electrical Engineeringa Department of Computer Science and Information Engineeringb Graduate Institute of Networking and Multimediac National Taiwan University [email protected], [email protected], [email protected] Abstract— In data-centric wireless sensor networks, data are alleviates the effort of node addressing and address reconfig- no longer sent by the sink node’s address. Instead, the sink uration in large-scale mobile sensor networks. node sends an explicit interest for a particular type of data. The source and the intermediate nodes then forward the data Forwarding in data-centric sensor networks is particularly according to the routing states set by the corresponding interest. challenging. It involves matching of the data content, i.e., This data-centric style of communication is promising in that it string-based attributes and values, instead of numeric ad- alleviates the effort of node addressing and address reconfigura- dresses. This content-based forwarding problem is well studied tion. However, when the number of interests from different sinks in the domain of publish-subscribe systems. It is estimated increases, the size of the interest table grows. It could take 10s to 100s milliseconds to match an incoming data to a particular in [3] that the time it takes to match an incoming data to a interest, which is orders of mangnitude higher than the typical particular interest ranges from 10s to 100s milliseconds. This transmission and propagation delay in a wireless sensor network. processing delay is several orders of magnitudes higher than The interest table lookup process is the bottleneck of packet the propagation and transmission delay.
    [Show full text]
  • Suffix Trees, Suffix Arrays, BWT
    ALGORITHMES POUR LA BIO-INFORMATIQUE ET LA VISUALISATION COURS 3 Raluca Uricaru Suffix trees, suffix arrays, BWT Based on: Suffix trees and suffix arrays presentation by Haim Kaplan Suffix trees course by Paco Gomez Linear-Time Construction of Suffix Trees by Dan Gusfield Introduction to the Burrows-Wheeler Transform and FM Index, Ben Langmead Trie • A tree representing a set of strings. c { a aeef b ad e bbfe d b bbfg e c f } f e g Trie • Assume no string is a prefix of another Each edge is labeled by a letter, c no two edges outgoing from the a b same node are labeled the same. e b Each string corresponds to a d leaf. e f f e g Compressed Trie • Compress unary nodes, label edges by strings c è a a c b e d b d bbf e eef f f e g e g Suffix tree Given a string s a suffix tree of s is a compressed trie of all suffixes of s. Observation: To make suffixes prefix-free we add a special character, say $, at the end of s Suffix tree (Example) Let s=abab. A suffix tree of s is a compressed trie of all suffixes of s=abab$ { $ a b $ b b$ $ ab$ a a $ b bab$ b $ abab$ $ } Trivial algorithm to build a Suffix tree a b Put the largest suffix in a b $ a b b a Put the suffix bab$ in a b b $ $ a b b a a b b $ $ Put the suffix ab$ in a b b a b $ a $ b $ a b b a b $ a $ b $ Put the suffix b$ in a b b $ a a $ b b $ $ a b b $ a a $ b b $ $ Put the suffix $ in $ a b b $ a a $ b b $ $ $ a b b $ a a $ b b $ $ We will also label each leaf with the starting point of the corresponding suffix.
    [Show full text]