The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
humanreadablemag.com
The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
1–10 of 42 posts
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#2Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#3This might be a stupid question: why is the fact it’s a _suffix_ tree important? (as opposed to building a similar structure with prefixes)
So yeah its a prefix tree, but a prefix tree of all the suffixes.
And now to answer your question. If you naively put every suffix into a regular prefix tree, you would get the same lookup performance. BUT, since the suffixes will share a lot of suffixes, which the prefix tree can't compress you have a lot more memory consumption.
The suffix tree avoids this by essentially performing compression on the suffix as well, so that you simply have pointers to shared suffixes of suffixes, which point to the root.
In the end it's like a diamond shape I guess, trie in the front, compression in the back.
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#4Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#5This might be a stupid question: why is the fact it’s a _suffix_ tree important? (as opposed to building a similar structure with prefixes)
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#6This might be a stupid question: why is the fact it’s a _suffix_ tree important? (as opposed to building a similar structure with prefixes)
The reason you would want a suffix tree (over a prefix trie) is that suffix trees are quite useful for computing the longest common substring of two strings (they can do it in linear time).
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#7This might be a stupid question: why is the fact it’s a _suffix_ tree important? (as opposed to building a similar structure with prefixes)
But suppose you want to look for the best match of string in a data stream with no predetermined length e.g. a TCP pipe. Then a suffix tree will allow you to process each incoming character in constant time. A prefix tree will not.
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#8This might be a stupid question: why is the fact it’s a _suffix_ tree important? (as opposed to building a similar structure with prefixes)
Moreover, how would you even start searching for a substring using a prefix tree? You can't start at the root, because the substring wouldn't be a prefix. It doesn't help you there at all.
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#9Also interesting to get into are suffix arrays which you could construct from a tree. Then there is a notion of generalized suffix arrays, where you mix multiple suffix arrays into a big suffix array. Then you can give fast answers like: what is the longest common prefix between the several tokens, whereas the tokens of your individual suffix arrays could be letters from an alphabet (so you construct a suffix array f…
Suffix trees are cool, but they’re just the entry point to a world of wonderful data structures and algorithms.
Re: The Wonders of the Suffix Tree Through the Lens of Ukkonen’s Algorithm
#10Every time I expect it to show up (e.g., for pattern matching in databases), I almost always see something else used instead (e.g., trigrams)