Originally, the algorithm is too long to fit in the frame. If I use the \scalebox{0.8}{}, it can fit in the frame but doesn't look like to be centered in the frame. Here is the code and output. First picture is for the original code, second is for the code with scalebox. Are there any methods to make the the algorithm to both fit in and be centered in the frame. (And I think the hat of A in the last line is ugly.)
\documentclass{beamer}
\mode<presentation>
{
\usetheme{CambridgeUS}
\usecolortheme{dolphin}
\usecolortheme{rose}
\setbeamerfont*{title}{shape=\itshape, family=\rmfamily}
\setbeamercovered{transparent}
}
\usepackage{algorithm2e}
\begin{document}
\begin{frame}{Hello world}
\begin{center}
\begin{minipage}{0.8\linewidth}
%\scalebox{0.8}{
\begin{algorithm}[H]
\DontPrintSemicolon
\KwSty{type} brow : \KwSty{int}$[M+1]$\;
\KwSty{type} bcol : \KwSty{int}$[N+1]$\;
\KwSty{type} val : \KwSty{real}$[k]$\;
\KwSty{type} val\_ptr : \KwSty{int}$[K+1]$\;
\KwSty{type} ind : \KwSty{int}$[K]$\;
\KwSty{type} ptr : \KwSty{int}$[M+1]$\;
\everypar={\nl}
\ForEach{block row $I$}{
$i_0 \leftarrow brow[I]$\;
$r \leftarrow brow[I+1]$\;
Let $\hat{y} \leftarrow y_{i_0:(i_0+r-1)}$\;
\For{$b=ptr[I] \KwTo ptr[I+1]$}{
$J \leftarrow ind[b]$\;
$j_0 \leftarrow bcol[J]$\;
$c \leftarrow bcol[J+1]-bcol[J]$\;
Let $\hat{x} \leftarrow x_{j_0:(j_0+c-1)}$\;
Let $\hat{A} \leftarrow a_{i_0:(i_0+r-1),j_0:(j_0+c-1)}$\;
Perform $r \times c$ block multiply, $\hat{y} \leftarrow \hat{y}+\hat{A} \cdot \hat{x}$\;
}
}
\end{algorithm}
%}
\end{minipage}
\end{center}
\end{frame}
\end{document}



\let\Tiny\tinyin the preamble. Try upgrading your TeX distribution. – karlkoeller Jan 04 '15 at 09:55