To learn algorithms either you should attend classes or read some books. Here is a list of books often recommended to beginners.
- Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
- Algorithms by by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani
- Algorithms in a Nutshell by George T. Heineman, Gary Pollice, Stanley Selkow
- The Algorithm Design Manual by Steven S Skiena
- Algorithms (4th Edition) by Robert Sedgewick, Kevin Wayne