Guarded commands, nondeterminacy and formal derivation of programs
Communications of the ACM
Concrete Mathematics: A Foundation for Computer Science
Concrete Mathematics: A Foundation for Computer Science
FUNCTIONAL PEARL: Enumerating the rationals
Journal of Functional Programming
Which Mathematics for the Information Society?
TFM '09 Proceedings of the 2nd International Conference on Teaching Formal Methods
Designing an algorithmic proof of the two-squares theorem
MPC'10 Proceedings of the 10th international conference on Mathematics of program construction
On Euclid's algorithm and elementary number theory
Science of Computer Programming
Hi-index | 0.00 |
We derive an algorithm that enables the rationals to be efficiently enumerated in two different ways. One way is known and is credited to Moshe Newman; it corresponds to a deforestation of the so-called Calkin-Wilf tree of rationals. The second is new and corresponds to a deforestation of the Stern-Brocot tree of rationals. We show that both enumerations stem from the same simple algorithm. In this way, we construct a Stern-Brocot enumeration algorithm with the same time and space complexity as Newman's algorithm.