Possible Duplicate:
Why does an algorithm's label have to appear after the caption?
I have the following in a paper:
See~\ref{fig:quicksort}.
\begin{figure}
\label{fig:quicksort}
\begin{algorithm}[H]
\caption*{\textsc{QuickSort}(\emph{Array, Left, Right})}
\label{alg:quicksort}
\begin{algorithmic}[1]
\If{$Left < Right$}
\State PivotIndex $\gets$ \textsc{Partition}(\emph{Array, Left, Right})
\State \textsc{QuickSort}(\emph{Array, Left,} $PivotIndex - 1$)
\State \textsc{QuickSort}(\emph{Array,} $PivotIndex + 1,$ \emph{Right})
\EndIf
\end{algorithmic}
\end{algorithm}
\caption{\small{\textbf{Serial Implementation of the In-Place Quicksort Algorithm} - Brief Description}}
\end{figure}
I must have compiled this at least twenty times now but I still get errors about undefined references and I get a nice litte ?? in my document. What am I doing wrong here?
I am using the following packages: fullpage, algorithm, algpseudocode, and caption.
Screenshot of document in progress:

algorithmenvironment inside afigure. However, the\labelcommand must go after the caption it should refer to. – egreg Mar 11 '12 at 09:23\floatstyle{plain} \restylefloat{algorithm}in the preamble does what you want. – Andrey Vihrov Mar 11 '12 at 09:40