\begin{algorithm} \caption{Mergable Heap Implemented with Unsorted List} \begin{algorithmic} \PROCEDURE{MakeHeap}{} \STATE Let $L$ be an empty doubly linked list with a sentinel node, i.e. $L.nil.prev = L.nil.next = L.nil$ \RETURN $L$ \ENDPROCEDURE \STATE \PROCEDURE{Insert}{$L, x$} \STATE $x.prev = L.nil$ \STATE $x.next = L.nil.next$ \STATE $L.nil.next.prev = x$ \STATE $L.nil.next = x$ \ENDPROCEDURE \STATE \PROCEDURE{Minimum}{$L$} \IF{$L.nil.next = L.nil$} \RETURN $L.nil$ \ENDIF \STATE $x = L.nil.next$ \STATE $p = x$ \WHILE{$p \ne L.nil$} \IF{$p.key < x.key$} \STATE $x = p$ \ENDIF \STATE $p = p.next$ \ENDWHILE \RETURN $x$ \ENDPROCEDURE \STATE \PROCEDURE{ExtractMin}{$L$} \STATE $x =$ \CALL{Minimum}{$L$} \IF{$x \ne L.nil$} \STATE $x.prev.next = x.next$ \STATE $x.next.prev = x.prev$ \ENDIF \RETURN $x$ \ENDPROCEDURE \STATE \PROCEDURE{Union}{$L_1, L_2$} \STATE $L_1.nil.prev.next = L_2.nil.next$ \STATE $L_2.nil.next.prev = L_1.nil.prev$ \STATE $L_2.nil.prev.next = L_1.nil$ \STATE $L_1.nil.prev = L_2.nil.prev$ \RETURN $L_1$ \ENDPROCEDURE \end{algorithmic} \end{algorithm}