[Tex/LaTex] Add lines to the bottom and top of algorithm

algorithms

I am trying to write some psuedocode for my algorithm. Is it possible to add lines to the button and the top of the algorithm? If yes how?

Code:

\documentclass{article}
\usepackage[]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{$next\_id, speed,stop\_distance, mac$}
\KwResult{Find the initializer. }
 int $next\_id1$ = find a  record with $speed > 30$ for this $mac$;\\
 int $next\_id2$ = find record with $speed <7$ and $stop\_distance < 60$ for this mac;\\
 \If{$next\_id1 < next\_id2$}{
   find the related $stop\_name$ for this mac;
   return  $stop\_name$;
 }
\caption{Algorithm to find intializer.}
\end{algorithm}
\end{document}

Best Answer

You can use ruled option to the package algorithm2e.

\documentclass{article}
\usepackage[ruled]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{$next\_id, speed,stop\_distance, mac$}
\KwResult{Find the initializer. }
 int $next\_id1$ = find a  record with $speed > 30$ for this $mac$;\\
 int $next\_id2$ = find record with $speed <7$ and $stop\_distance < 60$ for this mac;\\
 \If{$next\_id1 < next\_id2$}{
   find the related $stop\_name$ for this mac;
   return  $stop\_name$;
 }
\caption{Algorithm to find intializer.}
\end{algorithm}
\end{document}

enter image description here

There are other options as seen in this screen shot from the manual:

enter image description here