algorithm.sty not found error in LaTeX

If you use the algorithm package in your LaTeX document, you might get this error on compiling it:

LaTeX Error: File `algorithm.sty' not found.

On Ubuntu, this LaTeX package is bundled in the texlive-science package. Install this package and the error should be gone:

$ sudo apt-get install texlive-science

Tried with: Ubuntu 14.04

Inserting an algorithm in LaTeX

A simple algorithm in LaTeX

One of the simple and beautiful ways to insert algorithms or procedures into a LaTeX document is using the algorithmicx package. The simple example given below generated the above figure. For more control structures and configurations check out the package documentation.

Tried with: MikTeX 2.9 on Windows 7 64-bit