在Burrows-Wheeler变换之前分析一个字符串?

时间:2013-06-23 09:50:36

标签: c algorithm compression analysis burrows-wheeler-transform

如果我们将此aaabccba视为输入字符串,则在输入上应用Burrows-Wheeler变换后,baaacacb将是输出字符串。观察输出,你会发现两个丛生的c是分开的。很明显,输入字符串将导致比输出更好的压缩。

如何决定是否对输入字符串应用Burrows-Wheeler变换?我们可以做一些快速分析来做出决定吗?

2 个答案:

答案 0 :(得分:1)

尝试使用比BWT更快的速度压缩它,例如lz4,看看它压缩了多少。然后,您可以根据您为应用程序推导出的任何条件,通过实验在该比率上设置一个阈值,然后应用BWT。

答案 1 :(得分:0)

最简单的解决方案是实际压缩每个字符串,并查看压缩程度最小的结果。

如果您不想这样做,您可以计算每组的长度:

aaabccba -> aaa b cc b a

    aaa has length 3
    b has length 1
    cc has length 2
    b has length 1
    a has length 1

    there where 3 groups of length 1
    there where 1 group of length 2
    there where 1 group of length 3
                ^

    -> [3, 1, 1]
baaacacb -> b aaa c a c b

    b has length 1
    aaa has length 3
    c has length 1
    a has length 1
    c has length 1
    b has length 1

    there where 5 groups of length 1
    there where 0 groups of length 2
    there where 1 group of length 3
                ^

    -> [5, 0, 1]
  • 按字典顺序比较列表:3 < 5所以[3, 1, 1] < [5, 0, 1] - 选择最小的列表。

  • 或者,您可以撤消列表:[1, 1, 3] > [1, 0, 5] - 选择最大的列表。

  • 比较它们的另一种方法是总计数:3+1+1=5 < 5+0+1=6。 - 选择较小金额的那个。