[Tex/LaTex] Place two algorithm into two column

algorithmicalgorithmstwo-column

I have single column page. I would like to add my two algorithm into two column. How can I do this? My algorithms are below.

\begin{algorithm}[h]
\caption{Resolve 1}
\begin{algorithmic}
\scriptsize
\STATE $ P_i $ sends $ id,t_1,t_2,P_j,h_j $ to TTP where $ P_j $ is the party that does not send $ V_j^{(2)} $ to $ P_i $, TTP does the following and sends the returned message to $P_i$:

\IF{$ currenttime > t_1 $}
\STATE \textbf{send} $ msg $ ``Abort Resolve 1"
\ELSE
\IF { Search($ id, t_1, t_2 $) == NULL }
    \STATE \lst = Create($ id, t_1, t_2 $) 
    \STATE \slst = Create($ id, t_1, t_2 $)
    \STATE \lst.add($ P_i, (P_j,h_j) $) 
    \STATE \textbf{send} $ msg $ ``Come after $ t_2 $"
\ELSE 
    \STATE \lst.add($ P_i, (P_j,h_j $)) 
    \STATE \textbf{send} $ msg $ ``Come after $ t_2 $"
\ENDIF
  \ENDIF
  \end{algorithmic}
  \end{algorithm}

\begin{algorithm}[h]
\caption{Resolve 3}
\begin{algorithmic}
\scriptsize
\STATE $ P_i $ comes either to receive decryption of a $ \{V^(2)_t\}_{t \in M} $ where $ M \subseteq N $ or his desired decryption shares from TTP's record.
\STATE $ condition $  =  \lst.isEmpty()
\IF {$ condition $ is false }
\STATE \textbf{send} msg ``Protocol is aborted"
\ELSE
\IF {$ P_i $ give $\{V^(2)_t\}_{t \in M} $}
    \FORALL {$ t $ in $ M $}
        \STATE \textbf{send} Decrypt($ sk, V^(2)_t $)
    \ENDFOR 
\ELSE 
    \FORALL {$ t $ in $ \slst $ as $ (P_i, shares_t) $}
    \STATE \textbf{send} $ shares_t $
    \ENDFOR
\ENDIF
\ENDIF

\end{algorithmic}
\end{algorithm}

Best Answer

Do you mean like this? I have used mulitcols inside algorithmic with a \columnbreak between the algorithms. Note there is only one caption command available.

Sample output

\documentclass{article}

\usepackage{algorithm,algorithmic,multicol}

\begin{document}

\begin{algorithm}[h]
  \caption{Resolve 1 and 3}
  \begin{multicols}{2}
    \begin{algorithmic}
      \scriptsize
      \STATE $ P_i $ sends $ id,t_1,t_2,P_j,h_j $ to TTP where $ P_j $ is the party that does not send $ V_j^{(2)} $ to $ P_i $, TTP does the following and sends the returned message to $P_i$:

      \IF{$ currenttime > t_1 $}
      \STATE \textbf{send} $ msg $ ``Abort Resolve 1"
      \ELSE
      \IF { Search($ id, t_1, t_2 $) == NULL }
      \STATE lst = Create($ id, t_1, t_2 $) 
      \STATE slst = Create($ id, t_1, t_2 $)
      \STATE lst.add($ P_i, (P_j,h_j) $) 
      \STATE \textbf{send} $ msg $ ``Come after $ t_2 $"
      \ELSE 
      \STATE logical lst.add($ P_i, (P_j,h_j $)) 
      \STATE \textbf{send} $ msg $ ``Come after $ t_2 $"
      \ENDIF
      \ENDIF
    \end{algorithmic}
    \columnbreak
    \begin{algorithmic}
      \scriptsize
      \STATE $ P_i $ comes either to receive decryption of a $ \{V^(2)_t\}_{t \in M} $ where $ M \subseteq N $ or his desired decryption shares from TTP's record.
      \STATE $ condition $  =  lst.isEmpty()
      \IF {$ condition $ is false }
      \STATE \textbf{send} msg `Code` 
      `Protocol is aborted"
      \ELSE
      \IF {$ P_i $ give $\{V^(2)_t\}_{t \in M} $}
      \FORALL {$ t $ in $ M $}
      \STATE \textbf{send} Decrypt($ sk, V^(2)_t $)
      \ENDFOR 
      \ELSE 
      \FORALL {$ t $ in $ slst $ as $ (P_i, shares_t) $}
      \STATE \textbf{send} $ shares_t $
      \ENDFOR
      \ENDIF
      \ENDIF
    \end{algorithmic}
  \end{multicols}
\end{algorithm}

\end{document}