Introduction to the design and analysis of algorithms