Table of Contents
Fetching ...

Fast Rational Search via Stern-Brocot Tree

Connor Weyers, N. V. Vinodchandran

TL;DR

This work introduces a compressed Stern–Brocot tree traversal to solve rational search with comparison queries, achieving a worst-case bound of about 2.5849 log2 n and a lower bound of about 2.4189 log2 n. It leverages an exponential-binary search hybrid to determine run lengths in a run-length encoding of the Stern–Brocot path, and connects this approach to continued fractions. The authors extend the method to unbounded rational search and to finding best rational approximations of unknown real numbers, and contrast performance with the Kwek–Mehlhorn algorithm through experiments. The results show competitive behavior with clear theoretical bounds and practical applicability, though not yet optimal in the worst case and with some runtime trade-offs.

Abstract

We revisit the problem of rational search: given an unknown rational number $α= \frac{a}{b} \in (0,1)$ with $b \leq n$, the goal is to identify $α$ using comparison queries of the form ``$β\leq α$?''. The problem has been studied several decades ago and optimal query algorithms are known. We present a new algorithm for rational search based on a compressed traversal of the Stern--Brocot tree, which appeared to have been overlooked in the literature. This approach also naturally extends to two related problems that, to the best of our knowledge, have not been previously addressed: (i) unbounded rational search, where the bound $n$ is unknown, and (ii) computing the best (in a precise sense) rational approximation of an unknown real number using only comparison queries.

Fast Rational Search via Stern-Brocot Tree

TL;DR

This work introduces a compressed Stern–Brocot tree traversal to solve rational search with comparison queries, achieving a worst-case bound of about 2.5849 log2 n and a lower bound of about 2.4189 log2 n. It leverages an exponential-binary search hybrid to determine run lengths in a run-length encoding of the Stern–Brocot path, and connects this approach to continued fractions. The authors extend the method to unbounded rational search and to finding best rational approximations of unknown real numbers, and contrast performance with the Kwek–Mehlhorn algorithm through experiments. The results show competitive behavior with clear theoretical bounds and practical applicability, though not yet optimal in the worst case and with some runtime trade-offs.

Abstract

We revisit the problem of rational search: given an unknown rational number with , the goal is to identify using comparison queries of the form ``?''. The problem has been studied several decades ago and optimal query algorithms are known. We present a new algorithm for rational search based on a compressed traversal of the Stern--Brocot tree, which appeared to have been overlooked in the literature. This approach also naturally extends to two related problems that, to the best of our knowledge, have not been previously addressed: (i) unbounded rational search, where the bound is unknown, and (ii) computing the best (in a precise sense) rational approximation of an unknown real number using only comparison queries.

Paper Structure

This paper contains 9 sections, 1 theorem, 30 equations, 2 figures, 4 tables, 2 algorithms.

Key Result

Theorem 1

Let $\alpha$ be an unknown rational number in $(0,1)$. The algorithm Compressed Stern-Brocot Tree Search outputs $\alpha$ with no more than $2.5849\log_2n$ queries of the form $"\beta \leq \alpha"$ where $n$ is the denominator of $\alpha$.

Figures (2)

  • Figure 1: Stern-Brocot Tree up to level 6, starting at 1/2. As examples ${1\over 3}={0+1\over 1+2}$ is the mediant of ${0\over 1}$ (not shown) and ${1\over 2}$, and ${5\over 7}={2+3\over 3+4}$ is the mediant of ${2\over 3}$ and ${3\over 4}$.
  • Figure 2: Queries taken by the Kwek-Mehlhorn and Compressed Stern-Brocot Tree Search algorithm for performing a rational search on a fraction $\frac{a}{b}$ such that $a<b \leq n$. Note that the maximum queries for the Kwek-Mehlhorn algorithm were not displayed in this graph because they are effectively the same as the average.

Theorems & Definitions (3)

  • Theorem 1
  • Claim 1
  • Claim 2