Optimal exact string matching based on su x arrays

Using the su x tree of a string S, decision queries of the type \Is P a substring of S?" can be answered in O(jP j) time and enumeration queries of the type \Where are all z occurrences of P in S?" can be answered inO(jP j+z) time, totally independent of the size of S. However, in large scale applications as genome analysis, the space requirements of the su x tree are a severe drawback. The su x array is a more space economical index structure. Using it and an additional table, Manber and Myers (1993) showed that decision queries and enumeration queries can be answered in O(jP j+log jSj) and O(jP j+log jSj+z) time, respectively, but no optimal time algorithms are known. In this paper, we show how to achieve the optimal O(jP j) and O(jP j+ z) time bounds for the su x array. Our approach is not con ned to exact pattern matching. In fact, it can be used to e ciently solve all problems that are usually solved by a top-down traversal of the su x tree. Experiments show that our method is not only of theoretical interest but also of practical relevance.