arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1403.4445cs.DScs.FL
收藏

最小文法的一个简单近似

A really simple approximation of smallest grammar

Artur Jeż

摘要:

在本文中,我们提出了一个非常简单的线性时间算法构造一个上下文无关文法的大小为O(g log(N/g))的输入字符串,其中N是输入字符串的大小和g的最佳语法生成这个字符串的大小。该算法适用于任意大小的字母表,但运行时间是线性的,假设输入字符串的字母表Sigma可以用1,ldots,N^c中的数字识别,对于某个常数c。具有这样的近似保证和运行时间的算法是已知的,然而所有这些算法都是非平凡的,并且涉及它们的分析。这里提出的算法计算的LZ 77分解和转换阶段的语法。在每个阶段中,它保持了一个LZ 77类的因子分解,最多有l个因子以及额外的O(l)个字母,其中l是原始LZ 77因子分解的大小。在一个阶段中,以贪婪的方式(通过从左到右的扫描和因式分解的帮助),我们选择一组连续的字母对来替换为新的符号,即构造的语法的非终结符。我们选择单词中至少2/3的字母,并且它们之间有O(l)许多不同的配对。因此有O(log N)个阶段,每个阶段都向文法引入O(l)个非终结符。一个更精确的分析产生了一个约束O(llog(N/l))。由于l \leq g,这产生期望的结合O(g log(N/g))。

英文摘要:

In this paper we present a really simple linear-time algorithm constructing a context-free grammar of size O(g log (N/g)) for the input string, where N is the size of the input string and g the size of the optimal grammar generating this string. The algorithm works for arbitrary size alphabets, but the running time is linear assuming that the alphabet Sigma of the input string can be identified with numbers from 1,ldots, N^c for some constant c. Algorithms with such an approximation guarantee and running time are known, however all of them were non-trivial and their analyses were involved. The here presented algorithm computes the LZ77 factorisation and transforms it in phases to a grammar. In each phase it maintains an LZ77-like factorisation of the word with at most l factors as well as additional O(l) letters, where l was the size of the original LZ77 factorisation. In one phase in a greedy way (by a left-to-right sweep and a help of the factorisation) we choose a set of pairs of consecutive letters to be replaced with new symbols, i.e. nonterminals of the constructed grammar. We choose at least 2/3 of the letters in the word and there are O(l) many different pairs among them. Hence there are O(log N) phases, each of them introduces O(l) nonterminals to a grammar. A more precise analysis yields a bound O(l log(N/l)). As l \leq g, this yields the desired bound O(g log(N/g)).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑