Algorithms and data structures : Foundations and probabilistic methods for design and analysis.