Fast Rational Search via Stern-Brocot Tree
Abstract
We revisit the problem of rational search: given an unknown rational number α = a/b ∈ (0,∞) with a,b ≤ n, 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 an 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. While the algorithm is simple and natural, one of our main contributions is its analysis: we give an upper and lower bound on its worst-case query complexity.
Fields of Study & Subjects
Algorithms and Data Compression
Machine Learning and Algorithms
Markov Chains and Monte Carlo Methods
Publication details
- Journal / source
- arXiv (Cornell University)
- Publication date
- 1 January 2026
- Language
- EN
- Document type
- Preprint