My last page of an article is similar to the one below.
On the second column, the fig. 4 is not placed on the top and the algorithm is not placed just below the fig. 4.
How can I fix this? The figure and algorithm are not quite related so I don't want to put them in the same float.
I believe that if I add text (or many lines of text) then it will work but I want to ensure they're not centered even when there is no text or litte text.
The solution here work for figure but not the algorithm.
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{array}
\usepackage{lipsum}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}
\newcolumntype{L}{>{$}l<{$}}
\newcommand\cpair[2]{%
\begin{tabular}{LL}#1 & #2\end{tabular}}
\algrenewcommand{\algorithmiccomment}[1]{\hfill#1}
\begin{document}
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{a caption}
\label{fig:a label}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{a caption}
\label{fig:a label}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{example-image-c}
\caption{a caption}
\label{fig:a label}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{a caption}
\label{fig:a label}
\end{figure}
\begin{algorithm}
\caption{Insertion-Sort køretid}\label{AlgRun}
\begin{algorithmic}[1]
\Procedure{insertion-sort}{$A,n$} \Comment \cpair{c_1}{n=0}
\State $inversions = 0$ \Comment \cpair{c_1}{n=1}
\State \textit{L}[0..\textit{n} - 1] be a new array.
\For{q=0}{n-1}
\State L[q] = A[q]
\EndFor
\For{j=1}{n-1}
\State $key = L[j]$
\State $i = j - 1$
\While{$ i \geq 0$ \textbf{and} $L[i] > key$}
\State L[ i + 1] = L[ i ]
\State $j = i - 1$
\State $inversions = inversions + 1$
\EndWhile
$L[i + 1] = key$
\EndFor
\Return{inversions}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}

