add algorithm for chapter 2 in beauty of programming book
optimization
modify some bugs