Design and analysis of algorithms