homework2 of Algorithms Analysis and Design