Table of Contents
Fetching ...

Bubble-Flip -- A New Generation Algorithm for Prefix Normal Words

Ferdinando Cicalese, Zsuzsanna Lipták, Massimiliano Rossi

TL;DR

This work addresses the enumeration and structural understanding of prefix normal words, binary strings where no factor exceeds the corresponding prefix in the number of $1$s. It introduces Bubble-Flip, a recursive generator that uses two operations, bubble and flip, guided by a partner function $\varphi(w)$, achieving $O(n)$ time per word and enabling generation of all PN words of a fixed length, including those sharing a fixed critical prefix, with options for lexicographic or Gray-code order. The authors also extend the theory to infinite prefix normal words via a flip-extension construction, proving that certain infinite PN words are ultimately periodic with computable period length and density, and they provide bounds on when periodicity appears. Together, these results yield a scalable PN-word enumerator, new Gray-code variants, and a framework to study infinite PN extensions and their combinatorial structure. The work opens avenues for counting PN words, investigating the distribution of critical prefixes, and refining understanding of infinite PN words and their densities.

Abstract

We present a new recursive generation algorithm for prefix normal words. These are binary strings with the property that no substring has more 1s than the prefix of the same length. The new algorithm uses two operations on binary strings, which exploit certain properties of prefix normal words in a smart way. We introduce infinite prefix normal words and show that one of the operations used by the algorithm, if applied repeatedly to extend the string, produces an ultimately periodic infinite word, which is prefix normal. Moreover, based on the original finite word, we can predict both the length and the density of an ultimate period of this infinite word.

Bubble-Flip -- A New Generation Algorithm for Prefix Normal Words

TL;DR

This work addresses the enumeration and structural understanding of prefix normal words, binary strings where no factor exceeds the corresponding prefix in the number of s. It introduces Bubble-Flip, a recursive generator that uses two operations, bubble and flip, guided by a partner function , achieving time per word and enabling generation of all PN words of a fixed length, including those sharing a fixed critical prefix, with options for lexicographic or Gray-code order. The authors also extend the theory to infinite prefix normal words via a flip-extension construction, proving that certain infinite PN words are ultimately periodic with computable period length and density, and they provide bounds on when periodicity appears. Together, these results yield a scalable PN-word enumerator, new Gray-code variants, and a framework to study infinite PN extensions and their combinatorial structure. The work opens avenues for counting PN words, investigating the distribution of critical prefixes, and refining understanding of infinite PN words and their densities.

Abstract

We present a new recursive generation algorithm for prefix normal words. These are binary strings with the property that no substring has more 1s than the prefix of the same length. The new algorithm uses two operations on binary strings, which exploit certain properties of prefix normal words in a smart way. We introduce infinite prefix normal words and show that one of the operations used by the algorithm, if applied repeatedly to extend the string, produces an ultimately periodic infinite word, which is prefix normal. Moreover, based on the original finite word, we can predict both the length and the density of an ultimate period of this infinite word.

Paper Structure

This paper contains 11 sections, 21 theorems, 15 equations, 3 figures, 2 tables, 4 algorithms.

Key Result

Lemma 1

Let $w\in {\cal L}_n$ such that $r = r(w)<n$ and let $j$ be an index with $r<j\leq n$. Then $w'= \mathop{\rm flip}(w,j)$ is not prefix normal if and only if there exists a $1 \leq k < r$ such that $|w_{r-k+1} \cdots w_r|_1 = P_w(k)$ and $|w_{k+1} \cdots w_{k+j-r} |_1= 0$.

Figures (3)

  • Figure 1: The words in ${\cal PN}(11010000)$ represented as a tree. If a node of the tree is word $w$, then its left child is $\mathop{\rm bubble}(w)$ and its right child is $\mathop{\rm flip}(w, \varphi(w)).$ In the tree, the position of $\varphi(w)$ is indicated, whenever $\varphi(w)\leq n$; bubble operations (in the left child) resp. flip operations (in the right child) are highlighted in bold. Algorithm \ref{['algo:pnw_descent']} generates these words by performing an in-order traversal of the tree. The corresponding list of words is given on the right.
  • Figure 2: A sketch of the computation tree of Algorithm \ref{['algo:pnw_descent']} for the set $w=110^{n-2}$, highlighting the subtrees corresponding to sets of prefix normal words with the same critical prefix.
  • Figure 3: The frequency of prefix normal words with given critical prefix length, in percentage of the total number of prefix normal words of length $n$, for $n=16$ (solid) and $n=32$ (dashed).

Theorems & Definitions (59)

  • Definition 1: Prefix normal words, prefix normal condition
  • Example 1
  • Definition 2: Critical prefix
  • Example 2
  • Definition 3: Combinatorial Gray Code
  • Definition 4: Operation $\mathop{\rm flip}$
  • Definition 5: Operation $\mathop{\rm bubble}$
  • Lemma 1
  • proof
  • Definition 6: Phi
  • ...and 49 more