Introduction to algorithms - Cormen, Thomas H. (MIT electrical engineering and computer science series, 1990)