Featured Book

LaTeX Beginners Guide

Who is online

In total there are 7 users online :: 1 registered, 0 hidden and 6 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Yahoo [Bot] and 6 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Writing Pseudo-code in Latex

Add tags Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).

Writing Pseudo-code in Latex

Postby nenu28 on Sat Jul 16th, 2011

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
(137.06 KiB) Downloaded 475 times
nenu28
 
Posts: 28
Joined: Mon Jun 27th, 2011

Re: Writing Pseudo-code in Latex

Postby Stefan_K on Sat Jul 16th, 2011

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
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6379
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Writing Pseudo-code in Latex

Postby nenu28 on Sun Jul 17th, 2011

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
nenu28
 
Posts: 28
Joined: Mon Jun 27th, 2011

Re: Writing Pseudo-code in Latex

Postby Stefan_K on Sun Jul 17th, 2011

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
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6379
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Writing Pseudo-code in Latex

Postby nenu28 on Tue Jul 19th, 2011

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).
Code: Select all  •  Open in writeLaTeX
\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
nenu28
 
Posts: 28
Joined: Mon Jun 27th, 2011


Return to Math & Science

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests