pushpendra singh
pushpendra singh

Reputation: 43

What is the advantage of Suffix tree over suffix array?

I have been studying about trie, suffix array and suffix tree.I know these data structures can be used to fast lookup and for many more applications. Now my question is, If suffix array is space efficient and easy to implement than what are the scenarios where suffix tree should be preferred over suffix array

Can you please list down the individual's advantages over one another.. Thanks in advance.

Upvotes: 0

Views: 1654

Answers (1)

m.raynal
m.raynal

Reputation: 3113

Here is the abstract from Suffix arrays:A new method for on-line string searches written by Udi Manber and Gene Myers.

link to the article.

It provides a list of advantages of the suffix array in comparison to the suffix tree structure in general ca

A new and conceptually simple data structure, called a suffix array, for on-line string searches is introduced in this paper. Constructing and querying suffix arrays is reduced to a sort and search paradigm that employs novel algorithms. The main advantage of suffix arrays over suffix trees is that, in practice, they use three to five times less space. From a complexity standpoint, suffix arrays permit on-line string searches of the type, ‘‘Is W a substring of A?’’ to be answered in time O(P + log N), where P is the length of W and N is the length of A, which is competitive with (and in some cases slightly better than) suffix trees. The only drawback is that in those instances where the underlying alphabet is finite and small, suffix trees can be constructed in O(N) time in the worst case, versus O(N log N) time for suffix arrays. However, we give an augmented algorithm that, regardless of the alphabet size, constructs suffix arrays in O(N) expected time, albeit with lesser space efficiency. We believe that suffix arrays will prove to be better in practice than suffix trees for many applications

To make it brief, let's say that the suffix array has a significantly lower space complexity and better space locality than the suffix tree ; the trade-off being that the suffix tree runs faster in terms of time complexity (O(n) versus O(n.log(n)). Both give the suffixes of a string online(you can receive the string one char at a time, you don't need the whole string to run the algorithm).

Another advantage of the suffix array is the adaptability, for a substring search for instance ; the structure will allow for easier use of the data. It is also easier to implement as well.

Upvotes: 1

Related Questions