Table of Contents
Fetching ...

Generating a Gray code for prefix normal words in amortized polylogarithmic time per word

Péter Burcsi, Gabriele Fici, Zsuzsanna Lipták, Rajeev Raman, Joe Sawada

TL;DR

This work addresses the efficient exhaustive generation of prefix normal words of length $n$ and the associated membership problem. By showing that prefix normal words form a bubble language, the authors apply a generic bubble-language generation framework to produce a cool-lex Gray code, first giving a $O(n^2)$-based approach and then achieving an improved amortized time of $O(\log^2 n)$ per word through a refined, $(s,t)$-structured membership test and an efficient update of run-based prefix-maxima. Key contributions include a novel bubble-language characterization via the computation tree, a practical two-phase membership tester, and concrete Gray-code generation for PN words across all weights, with an explicit example for $n=7$. The results advance combinatorial generation for a nontrivial language and connect to jumbled pattern matching, providing both theoretical and practical improvements over prior $O(n)$-per-word generation and offering several open problems for closed-form enumeration, constant-amortized generation, and faster worst-case testing.

Abstract

A prefix normal word is a binary word with the property that no substring has more $1$s than the prefix of the same length. By proving that the set of prefix normal words is a bubble language, we can exhaustively list all prefix normal words of length $n$ as a combinatorial Gray code, where successive strings differ by at most two swaps or bit flips. This Gray code can be generated in $\Oh(\log^2 n)$ amortized time per word, while the best generation algorithm hitherto has $\Oh(n)$ running time per word. We also present a membership tester for prefix normal words, as well as a novel characterization of bubble languages.

Generating a Gray code for prefix normal words in amortized polylogarithmic time per word

TL;DR

This work addresses the efficient exhaustive generation of prefix normal words of length and the associated membership problem. By showing that prefix normal words form a bubble language, the authors apply a generic bubble-language generation framework to produce a cool-lex Gray code, first giving a -based approach and then achieving an improved amortized time of per word through a refined, -structured membership test and an efficient update of run-based prefix-maxima. Key contributions include a novel bubble-language characterization via the computation tree, a practical two-phase membership tester, and concrete Gray-code generation for PN words across all weights, with an explicit example for . The results advance combinatorial generation for a nontrivial language and connect to jumbled pattern matching, providing both theoretical and practical improvements over prior -per-word generation and offering several open problems for closed-form enumeration, constant-amortized generation, and faster worst-case testing.

Abstract

A prefix normal word is a binary word with the property that no substring has more s than the prefix of the same length. By proving that the set of prefix normal words is a bubble language, we can exhaustively list all prefix normal words of length as a combinatorial Gray code, where successive strings differ by at most two swaps or bit flips. This Gray code can be generated in amortized time per word, while the best generation algorithm hitherto has running time per word. We also present a membership tester for prefix normal words, as well as a novel characterization of bubble languages.

Paper Structure

This paper contains 14 sections, 14 theorems, 11 equations, 2 figures, 3 tables, 7 algorithms.

Key Result

Lemma 2.3

Let $w$ be a binary word.

Figures (2)

  • Figure 1: The computation tree $T_d^n$ for $n=7,d=4$. Prefix normal words in bold.
  • Figure 2: Illustration of Lemma \ref{['lemma:isPNF']}. On the right we have the two cases of a substring $u$ (in gray) of $w'$ which may violate the prefix normal property.

Theorems & Definitions (19)

  • Definition 2.1
  • Definition 2.2
  • Lemma 2.3: BFLRS17
  • Definition 2.4
  • Lemma 2.5
  • Lemma 2.6
  • Lemma 2.7
  • Theorem 2.8: BG19, Thm. 1
  • Lemma 2.9
  • Theorem 2.10
  • ...and 9 more