arrays - 使用曼伯迈尔斯算法的后缀数组

标签 arrays algorithm data-structures suffix-array

我尝试过研究论文 http://webglimpse.net/pubs/suffix.pdf 中的理论。

但是当他们说时我有点迷失

Let Ai be the first suffix in the first bucket (i.e., Pos[0] = i), and consider Ai-h (if i-h < 0, then we ignore Ai and take the suffix of Pos[1], and so on). Since Ai starts with the smallest h-symbol string, Ai-h should be the first in its 2h-bucket.

我无法理解这个说法。为什么如果 i-h < 0 可以忽略 Ai-h。在第 1 阶段,当 i-h > 0 时,如何在 const 时间内确定位置?

一个示例 impl 是 http://belbesy.wordpress.com/2012/10/10/spoj-649-distinct-substrings-suffix-arrays-nlgn/

最佳答案

我强烈建议不要尝试理解 C++ 代码,而是浏览一下此 Python implementation of the Manbers-Myers suffix array construction algorithm ,手动,一个简单的 5 个字符示例。

因为Python版本只有大约15行代码,所以很容易理解。

即使你不懂 Python,也可以将其视为伪代码,并通过 Google 搜索你不明白的语法。

就我个人而言,我手动浏览了一个 5 个字符的字符串,这足以帮助我理解该算法是如何工作的..

关于arrays - 使用曼伯迈尔斯算法的后缀数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18495728/

相关文章:

C 数组到 Char 指针

arrays - 如何将剪贴板放入二维数组(excel vba)

c++ - 编写一个通用的遍历函数,允许灵活地处理具有不同参数的多个函数

c - 对 struct c 数组中的 struct 数组进行排序

Java:循环遍历 CSV 并为另一列中的每个唯一值求和一列值的最有效方法

php - 检查数组值在 php 中是否存在

python - 带有生成器的 Python 中的 DFS 算法

python - 有效地生成所有小于 N 的合数(及其因式分解)

algorithm - 这个调度算法有更好的解决方案吗?

c# - 从 C# 流中读取无符号 24 位整数