Fundamentals of design and analysis of algorithms