Constructing a bijection

Solution 1:

Hint. Use Hilbert's Hotel to lodge some numbers in $(0,1)$; then deal with the two newcomers $0$ and $1$.

That is: find a sequence $x_1,x_2,\ldots,x_n,\ldots$ of numbers in $(0,1)$, all distinct. Map $x_1$ to $0$; map $x_2$ to $1$. Map $x_3$ to $x_1$. Map $x_4$ to $x_2$. And so on. As for the rest of the numbers in $(0,1)$, well, they can just stay where they are...

Solution 2:

Consider an injective function $h(n) = 1/(n+1)$ from $\mathbb{N}$ to $(0,1)$. You get a bijection setting

$f(0) = h(1) = 1/2$

$f(1) = h(2) = 1/3$

$f(1/(n+1)) = h(n+2) = 1/(n+3)$

$f(x) = x\quad$ if $\quad x \neq 1/n$.