SearcharxivSearch

arXiv subjects

Andrew Au

Publications and source records attributed to Andrew Au.

5 recordsLinked to original sources

Exact (n + 1) Comparison Complexity for the N-Repeated Element Problem

This paper establishes the exact comparison complexity of finding an element repeated $n$ times in a $2n$-element array containing $n+1$ distinct values, under the equality-comparison model with $O(1)$ extra space. We present a simple deterministic algorithm performing exactly $n+1$ comparisons and prove this bound \emph{tight}: any correct algorithm requires at least $n+1$ comparisons in the worst case. The lower bound follows from an adversary argument using graph-theoretic structure. Equality queries build an \emph{inequality graph} $I$; its complement $P$ (potential-equalities) must contain either two disjoint $n$-cliques or one $(n+1)$-clique to maintain ambiguity. We show these structures persist through $n$ comparisons via a ``pillar matching'' construction, but cannot survive the $(n+1)$st. The matching upper bound comes from a ``triangle'' construction that forces every component of $I$ to be a clique, so each hosts at most one copy of the repeated element and the single untested element must be the answer. This result provides a concrete, self-contained demonstration of exact lower-bound techniques, bridging toy problems with nontrivial combinatorial reasoning.

cs.DS

A Geometric Derivation of the Bitner--Ehrlich--Reingold Loopless Gray Code Algorithm

The Bitner--Ehrlich--Reingold algorithm generates the binary reflected Gray code with constant work per codeword, using a focus-pointer array. Its compact update is easy to state but gives little indication of why such pointers should exist. This note reconstructs a geometric route to the algorithm. The sequence of flipped bit positions is the ruler sequence, OEIS A007814. We realize its finite prefixes as in-order traversals of recursively expanding trees, decorate each activation with its nearest ancestor to the right, contract all stack operations between successive outputs into successor jumps, and prepare the bounded level-indexed stack by predicting its future slot values. This gives and proves a branch-based loopless generator. The construction grew from an earlier informal public exposition by the author. Viewing horizontal position in the tree as time then explains each stack-slot write as a prediction for the next activation at the same level. Finally, the two possible future roles---an inherited continuation for a right child and a default continuation for a left child---are scheduled together, leading to the two assignments of the published focus-pointer algorithm. The account is a reconstructed derivation, not a claim about the historical reasoning of Bitner, Ehrlich, or Reingold.

cs.DS

Do We Really Need to Read the Input? An Optimality Proof for Stone Game III

Stone Game III admits a standard backward dynamic program using $O(n)$ time and $O(1)$ auxiliary space. The upper bound is immediate, but its optimality raises a deceptively simple question: must a correct algorithm really inspect a linear number of input values? For the original problem, an all-zero instance gives a short indistinguishability proof that every position must be inspected. This argument appears to depend strongly on the possibility of a tie. We show that it does not. Even under the promise that every input has a winner, an adversary can force any deterministic algorithm to make $Ω(n)$ inspections by combining modular move control with indistinguishable input completions. We also extend the argument to positive but unbounded values, obtaining the same linear lower bound without zeros or ties. Together these results establish the asymptotic optimality of the standard $O(n)$-time, $O(1)$-space solution in several increasingly restrictive variants.

cs.DS

A Tight Lower Bound for Cycle Detection in Grid Graphs

We prove that any algorithm for detecting cycles in an $m \times n$ grid graph, where cells are colored and adjacency is defined by matching colors, must read all $mn$ cells in the worst case for all grids with $m \geq 2$ and $n \geq 2$. The proof is by adversary argument: we construct an adaptive adversary that maintains ambiguity -- one completion containing a cycle and one without -- until the final cell is read. The construction proceeds by tiling the grid with $2 \times 2$, $2 \times 3$, $3 \times 2$, and $3 \times 3$ blocks, each equipped with an independent block adversary, composed via a checkerboard isolation scheme.

cs.DS

Two Linear Passes Are Necessary for Sum-Exclude-Self Under Sublinear Space

We prove that any algorithm computing the sum-exclude-self of an unsigned $d$-bit integer array of length $n$ under sublinear space must perform two linear passes over the input. More precisely, the algorithm must read at least $n-1$ input elements before any output cell receives its final value, and at least $n - \lfloor t/d \rfloor$ additional elements thereafter, where $t = o(nd)$ bits is the working memory size. This gives a total of $2n - 1 - \lfloor t/d \rfloor$ element reads. A trivial modification of the standard two-pass algorithm achieves this bound exactly for all practical input sizes. The proof uses this toy problem as a worked example to demonstrate the choke-point technique for proving sublinear-space lower bounds.

cs.DS