Exercise for Introduction to Algorithm