Introduction to algorithms - Cormen, Thomas H.,; Leiserson, Charles E.,; Rivest, Ronald L.,; Stein, Clifford, (MIT Press, 2009)