April 19, 2013

How to write algorithm using Latex

I got a nice introductory video on writing algorithm using Latex.



This video uses the algorithmic package. You can find the basic set of commands of this package and few alternative packages here. The detail document is available here. The algorithmicx package (link) is an advanced package for writing algorithm.

A sample code snippet for the simple bubble sort algorithm using algorithmic package and its output is given below:

\begin{algorithm}
\begin{algorithmic}

\STATE $S$ is an array of integer
\FOR {$i$ in $1:length(S)-1)$}
    \FOR {$j$ in $(i+1):length(S)$ }
        \IF {$S[i]> S[j]$}
            \STATE swap $S[i]$ and $S[j]$
        \ENDIF
    \ENDFOR
\ENDFOR

\end{algorithmic}
\caption{Bubble sort algorithm}
\label{algo:bubble_sort}
\end{algorithm}






6 comments:

  1. This is a good post. This post give truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. thank you so much. Keep up the good works.
    Data Science Tutorial
    Data Science training in anna nagar
    Data science training in jaya nagar
    Data science training in pune
    Data Science Training in Marathahalli
    Data science training in kalyan nagar

    ReplyDelete
  2. Really it was an awesome article about JAVA, very interesting to read.You have provided an nice article,Thanks for sharing.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete