## LaTeX forum ⇒ Math & Science ⇒ Writing Pseudo-code in Latex

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
nenu28
Posts: 28
Joined: Mon Jun 27, 2011 11:24 am

### Writing Pseudo-code in Latex

Hi there!
I am just a beginner on writing pseudo-code in latex.
I need to write a pseudo-code (probably using algorithm and/or algorithmic packages) in latex, but could not get what I want.

I hereby attached the pseudo-code that I want to write.
Would you help me do that please?

Thank you and best regards!
Attachments
pseudo code.pdf

Stefan Kottwitz
Posts: 7887
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Hi,

nenu28 wrote:I am just a beginner on writing pseudo-code in latex.
I need to write a pseudo-code (probably using algorithm and/or algorithmic packages) in latex, but could not get what I want.

what's the problem? What did you get?

Stefan

nenu28
Posts: 28
Joined: Mon Jun 27, 2011 11:24 am
Hi Stefan_K and thanks for your message.

The problem is I want to write the pseudo-code (developed by C++ language) mentioned above.But I don't known how to type "{" or "}" on the lines 2, 8 and 10 of the algorithm.
Using algorithm and algorithmic packages, on the line 4 of the algorithm "for" is coming with "do".
So, is there a specific package to solve this problem ?

P.S: This Algorithm is developed bu C++ language /.

nenu

Stefan Kottwitz
Posts: 7887
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
It would be easier if you would show sample code besides the description. Btw. { and } need often t be written \{ and \} because { and } are special characters in LaTeX.

Stefan

nenu28
Posts: 28
Joined: Mon Jun 27, 2011 11:24 am
Hey Stephan,

I tried to manage to make the above algorithm by using both algorithm and algorithmic packages, but i got a problem with " line numbers " (See the code tex).
\listfiles     \documentclass[10pt]{report}     \usepackage {algorithm}     \usepackage {algorithmic}   \begin{document} \begin{algorithm}\caption{Apriori} \vspace{2mm} \textbf{Input:}\\D: transaction database;\\  Min\_sup: the minimum support threshold\\\textbf{Output:} frequent itemsets\\ \textbf{Description:}\begin{algorithmic}[1]\STATE $L_1$= find\_frequent\_1-itemsets(DB);  \STATE \textbf{for} (k=2; $L_{k-1}=\varphi; k++$) $\{$\STATE $C_{k}$= Apriori\_gen($L_{k-1}$);  \STATE \textbf{for each} transaction $t\in DB$ $\{$ \quad //scan DB for  counts  \STATE $C_t=$ subset$(C_k,t)$;\quad //get the subsets of $t$ that  are candidates  \STATE \textbf{for each} candidate $c\in C_t$  \STATE $c.count++$;  \STATE $\}$  \STATE $L_k=\{c\in C_k | c.count\geq min\_sup\}$  \STATE $\}$  \STATE return $L=\bigcup_kL_k$;  \STATE Procedure Apriori gen($L_{k-1}$: frequent$(k-1)$-itemsets)  \end{algorithmic}\end{algorithm}\end{document}

On the line 12, I don't want the number "12" appears. What should I do ? is there some technique to solve this ?

regards,

P.S: I just want to make this algorithm as shown the above attached pdf file

nenu