I am using algorithm2e to explain my algorithm and surrounding it within float environment for IEEETran class as suggested in How to use the algorithm2e package with IEEEtran class?
Below is a sample code:
\documentclass[conference]{IEEEtran}
\usepackage[font=scriptsize]{caption}
\usepackage{subcaption}
\usepackage[plain, vlined, linesnumbered, noresetcount]{algorithm2e}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
\begin{document}
\begin{figure}
\removelatexerror
\begin{algorithm}[H]
\textbf{struct} Node \{ \\
\Indp
\textbf{Int} key;\\
Node* child[2];\\
\Indm
\}; \\
\end{algorithm}
\hrule
\captionsetup{justification=centering}
\caption{Node structure}
\label{alg:NodeStructure}
\end{figure}
Figure \ref{alg:NodeStructure} represents a node in our tree
\end{document}
After I compile this code, I see a significant gap between the text and my algorithm. Is there any way to reduce this gap.