Excercise for data structure and algorithm.