🤖 AI Summary
This work addresses the problem of enumerating all binary strings of length ℓ without repetition, achieving both constant auxiliary space and constant time delay—properties exemplified by Gray codes. We introduce two novel computational models, the tape machine and the double-ended queue (deque) machine, and present corresponding algorithms that, for the first time, realize constant-delay, constant-space enumeration for this task. We further prove that stack machines and queue machines are inherently incapable of solving this problem. By leveraging techniques in state control, termination detection, and the construction of quasi-Gray and Gray codes, our algorithms efficiently generate quasi-Gray codes on tape machines and standard Gray codes on deque machines, thereby establishing a theoretical foundation for path queries in graph databases.
📝 Abstract
We give the first two algorithms to enumerate all binary words of $\{0,1\}^\ell$ (like Gray codes) while ensuring that the delay and the auxiliary space is independent from $\ell$, i.e., constant time for each word, and constant memory in addition to the $\ell$ bits storing the current word. Our algorithms are given in two new computational models: tape machines and deque machines. We also study more restricted models, queue machines and stack machines, and show that they cannot enumerate all binary words with constant auxiliary space, even with unrestricted delay. A tape machine is a Turing machine that stores the current binary word on a single working tape of length $\ell$. The machine has a single head and must edit its tape to reach all possible words of $\{0,1\}^{\ell}$ , and output them (in unit time, by entering special output states), with no duplicates. We construct a tape machine that achieves this task with constant delay between consecutive outputs, which implies that the machine implements a so-called skew-tolerant quasi-Gray code. We then construct a more involved tape machine that implements a Gray code. A deque machine stores the current binary word on a double-ended queue of length $\ell$, and stores a constant-size internal state. It works as a tape machine, except that it modifies the content of the deque by performing push and pop operations on the endpoints. We construct deque machines that enumerate all words of $\{0,1\}^\ell$ with constant-delay. The main technical challenge in this model is to correctly detect when enumeration has finished. Our work on deque machine is also motivated by other contexts in which endpoint modifications occur naturally. In particular, our result is a first step towards enumerating walks in directed graphs with constant delay and constant auxiliary space, addressing a core task in modern graph database query processing.