How to approach proving that walking this tree infinitely will product all natural numbers?

53 Views Asked by At

A binary tree with a root of "empty" always has a left node of 0 and a right node of 1. If we follow some path along this tree we can produce binary numbers with the least significant bit as the first step. For example travelling L->R->L->R would produce the sequence [0,1,0,1], which reversed gives 1010 (10 decimal).

It appears as though any binary number >= 0 should be able to be produced by this tree. If we were to walk along this tree infinitely and capture the path up to each node traversed, this would account for the set of all these integers >= 0.

How would I go about trying to prove this assumption?

Apologies if this is a common problem - it's difficult to google for. I did find this question which deals with the same type of tree but is asking a different question.

Also I don't have a mathematical background, but I've done some inductive proofs while at university many years ago.

1

There are 1 best solutions below

1
On BEST ANSWER

Every number can be expressed as an n-bit binary number $b_1b_2...b_n$ where each of the $b_i$ are $0$ or $1$. Note that $b_1$ will be $1$ unless the number is $0$. Simply replace each of the $b_i$ with $L$ if it is equal to $0$ and $R$, otherwise.