To learn algorithms either you should attend classes or read some books. Here is a list of books often recommended to beginners.

  1. Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
  2. Algorithms by by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani
  3. Algorithms in a Nutshell by George T. Heineman, Gary Pollice, Stanley Selkow
  4. The Algorithm Design Manual by Steven S Skiena
  5. Algorithms (4th Edition) by Robert Sedgewick, Kevin Wayne