Algorithm is really a tough subject to get rid off. You can go for Introduction to Algorithms, by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein