In a tabular environment, one can achieve an alternating color of rows by using the rowcolors command like so:
\documentclass[11pt,a4paper]{article}
\usepackage[table]{xcolor}
\begin{document}
\rowcolors{2}{gray!25}{white}
\begin{tabular}{cc}
\rowcolor{gray!50}
Table head & Table head \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values
\end{tabular}
\end{document}
This will produce:

How can I have a similar effect inside the algorithmic environment? I'm using the algorithmicx package.
EDIT: A MWE of a how I use algorithmicx follows.
\documentclass[a4paper]{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1] % [1] provides numbers in every line
\If {$i\geq maxval$}
\State $i\gets 0$
\Else
\If {$i+k\leq maxval$}
\State $i\gets i+k$
\EndIf
\EndIf
\end{algorithmic}
\caption{My algorithm}
\end{algorithm}
\end{document}
This yields:

