BCSL456D Program 11

PROGRAM:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}
	
	\begin{algorithm}
		\caption{Bubble Sort}
		\begin{algorithmic}[1]
			\Procedure{BubbleSort}{$A, n$}
			\For{$i \gets 0$ to $n-1$}
			\For{$j \gets 0$ to $n-1-i$}
			\If{$A[j] > A[j+1]$}
			\State Swap $A[j]$ and $A[j+1]$
			\EndIf
			\EndFor
			\EndFor
			\EndProcedure
		\end{algorithmic}
	\end{algorithm}
	
\end{document}

OUTPUT:

Leave a Reply

Your email address will not be published. Required fields are marked *