Introduction to the Design and Analysis of Algorithms