Introduction to Algorithm III section 6.5