Algorithms are getting numbered automatically but unable to get same for the functions.
In the following example, Algorithms are numbered as Algorithm 1 and Algorithm 2 by themselves but Functions didn't. Please advice.
\documentclass{ucbthesis}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{epstopdf}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{tikz,pgfplots,pgfplotstable}
\usepackage{tikz-qtree}
\usepackage{forest}
\usepackage{lettrine}
\usepackage{mathtools}
\usepackage{lscape}
\usepackage{pgf-pie}
\usepackage{caption}
\usetikzlibrary{positioning,shapes,arrows,shadows,patterns,intersections,calc,fit}
\usepackage{dashbox}
\usepackage{mathptmx}
\usepackage{xcolor}
\usepackage{hyperref}
\begin{document}
\begin{algorithm}
\caption{First Algorithm}
\For{$j \in V$}{
}
\end{algorithm}
\begin{algorithm}
\caption{Second Algorithm}
\For{$j \in V$}{
}
\end{algorithm}
\begin{function}
\label{function1}
\caption{First Function ()}
\For{$k \in R$}{
}
\end{function}
\begin{function}
\label{function2}
\caption{Second Function ()}
\For{$k \in R$}{
}
\end{function}
I am refering to function \ref{function1} and function \ref{function2}
\end{document}