码迷,mamicode.com
首页 > 其他好文 > 详细

Suffix array

时间:2014-11-08 13:38:45      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   sp   for   on   cti   bs   ad   

A suffix array is a sorted array of all suffixes of a given string. The definition is similar to Suffix Tree which is compressed trie of all suffixes of the given text. Any suffix tree based algorithm can be replaced with an algorithm that uses a suffix array enhanced with additional information and solves the same problem in the same time complexity.

A suffix array can be constructed from Suffix tree by doing a DFS traversal of the suffix tree. In fact Suffix array and suffix tree both can be constructed from each other in linear time.
Advantages of suffix arrays over suffix trees include improved space requirements, simpler linear time construction algorithms (e.g., compared to Ukkonen’s algorithm) and improved cache locality.

最简单的构建方法就是把所有的后缀取出来再排序,时间复杂度是O(n^2lgn),因为每次比较都要O(n)。有了suffix array之后的查找开销需要O(mlgn),m为pattern长度,用二分查找。

当然,对于构建和查找都有线性的算法。

 

转自:http://www.geeksforgeeks.org/suffix-array-set-1-introduction/

Suffix array

标签:http   io   ar   sp   for   on   cti   bs   ad   

原文地址:http://www.cnblogs.com/linyx/p/4083189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!