I have used these two packages for creating algorithm
\usepackage{algorithm2e}
\usepackage{algorithmicx}
But \begin{algorithm} shows as unrecognized command. Even \For, \While are shown as unrecognized. I don't understand. I'm using TexStudio as editor.
Here is a sample code
\documentclass[12pt,a4paper,oneside,oldfontcommands]{memoir}
\usepackage{algorithm2e}
\usepackage{algorithmicx}
\begin{document}
\begin{algorithm}
\caption{Retiming Algorithm to compute Shortest Path}
Set count = 1 \linebreak
\While{count $\le$ V}{
Set W(U,V) = $\infty$ \linebreak
Set D(U,V) = -1 \linebreak
count $\gets$ count + 1
}
\end{algorithm}
\end{document}
If I run above code, I get no errors but \While, \begin{algorithm} are coming as unrecognized commands. I'm not good at LaTeX. I've used google as source to write this.