Location:
Search - suffix arr
Search list
Description: 后缀数组的一个C++实现,在字符串统计中有很大作用。-Suffix array of a C++ implementation, plays a significant role in statistics in the string.
Platform: |
Size: 2048 |
Author: Fancy |
Hits:
Description: arr[]为数据数列,即这个串.如果有n个数,存为arr[0]~arr[n-1],并且保证每个数大于0,小于ASCII。
调用参数前,设置:arr[n]=0,n++
这样得出的sa[]数列:sa[0]肯定等于n,即排名为0的是第n个打头的后缀串,这个是我们加上去的,是无用的。
sa[1]才表示真正的串中排名为1(即第一)的串在arr[]中的起始位置
rank[i]=j数列:以第i个打头的串排名为j,可知,rank[n]=0。
height[i]=j表示排名为i的串和它前面一个串(即i-1)的公共前缀。可知height[]的有效范围为2~n
height[1]是排名为0的和排名为1的公共前缀,而排名为0的是我们加上去的arr[n]=0,所有必定为0且没有意义-arr [] is the number of data columns, and that the string. if there are n number of save arr [0] to arr [n-1], and to ensure that each number is greater than 0 and less than an ASCII. Before the call parameters set: arr [n] = 0, n++ This gives sa [] series: sa [0] is certainly equal to n, that is ranked 0 starts with the n-suffix string, this is our plus up, is useless. sa [1] before the real string# 1 (first) string starting position rank in arr [] [i] = j series: i-starts with the string rank j, we can see rank [n] = 0. height [i] = j indicates the ranking is a string of i, and in front of it a string (i.e., i-1) of the common prefix. Seen height [] the effective range of 2 ~ n height [1] is a ranking of 0 and ranked as one of the common prefix ranked 0 we add to the arr [n] = 0, all must be 0 and does not make sense
Platform: |
Size: 1024 |
Author: 陶翔 |
Hits: