<s>[INST] How to construct a bijection from $(0, 1)$ to $[0, 1]$? 
Possible Duplicate:
Bijection between an open and a closed interval
How do I define a bijection between $(0,1)$ and $(0,1]$? 

I wonder if I can cut the interval $(0,1)$ into three pieces:
$(0, \frac{1}{3})\cup(\frac{1}{3},\frac{2}{3})\cup(\frac{2}{3},1)$, in which I'm able to map point $\frac{1}{3}$ and $\frac{2}{3}$ to $0$ and $1$ respectively.
Now the question remained is how to build a bijection mapping from those three intervels to $(0,1)$.
Or, my method just goes in a wrong direction. Any correct approaches?
 [/INST] The idea you mention, with mild modification, will work. Please note that what is below is a minor variant of the solution given by Patrick da Silva.  
Your decomposition of $(0,1)$ is not quite complete. We want to write 
$$(0,1)=\left(0,\frac{1}{3}\right) \cup\left\{\frac{1}{3}\right\} \cup \left(\frac{1}{3},\frac{2}{3}\right)\cup \left\{\frac{2}{3}\right\}\cup \left(\frac{2}{3},1\right),$$
so $5$ "intervals," two of them kind of boring. From now on, we will call $\frac{2}{3}$ by the more cumbersome name $1-\frac{1}{3}$.
Use the identity function on the two endintervals $\left(0,\frac{1}{3}\right)$ and $\left(1-\frac{1}{3},1\right)$, and map $\frac{1}{3}$ to $0$, and $1-\frac{1}{3}$ to $1$.
This leaves $\left(\frac{1}{3},1-\frac{1}{3}\right)$, which needs to be bijectively mapped to $\left[\frac{1}{3},1-\frac{1}{3}\right]$.
Use the same trick on the interval $\left(\frac{1}{3},1-\frac{1}{3}\right)$ that we used on $(0,1)$. So this time the two special points "inside" that will be mapped to $\frac{1}{3}$ and $1-\frac{1}{3}$ respectively are $\frac{1}{3}+\frac{1}{9}$ and $1-\frac{1}{3}-\frac{1}{9}$. That leaves $\left(\frac{1}{3}+\frac{1}{9},1-\frac{1}{3}-\frac{1}{9}\right)$ to be mapped bijectively to $\left[\frac{1}{3}+\frac{1}{9},1-\frac{1}{3}-\frac{1}{9}\right]$. Continue, forever. As pointed out by Patrick da Silva, the point $\frac{1}{2}$ is not dealt with in this process: simply map it to itself. 
It would be notationally a little simpler to use the same idea to map $(-1,1)$ bijectively to $[-1,1]$, and use linear functions to take $(0,1)$ to $(-1,10$, and $[-1,1]$ to $[0,1]$ toadjust to our situation.
The advantage is that first "middle" interval is $\left(-\frac{1}{3},\frac{1}{3}\right)$, the second middle interval is $\left(-\frac{1}{9},\frac{1}{9}\right)$, and so on. 
</s>