Questions tagged [pseudocode]

{pseudocode} is a compact and informal description of a computer programming algorithm.

214 questions
25
votes
3 answers

How to write pseudocode similar to code presented in "Beautiful Code" by J. R. Heard

I came across an astonishing piece of text, which is called "Beautiful Code, Compelling Evidence" by J. R. Heard. I was wondering if there is a package or something that allows me to present my code similar to how J. R. Heard presented his code. I…
Snowflake
  • 755
  • 7
  • 13
21
votes
5 answers

Bitwise operator in pseudo-code

I am translating a C++ program into pseudo-code using the algorithmicx package. Do you know how I can represent the C bitwise operator like the shifts (<< and >>) ? Until now I used power of 2 but it's not very convenient.
BenjaminB
  • 313
  • 1
  • 2
  • 7
8
votes
1 answer

algorithm2e: do N times

I want to write this in algorithm2e pseudocode: Do N times stuff that has to be done N times end or maybe Repeat N times stuff that has to be done N times end Since the loop body does not depend on a loop index, introducing one (like in a…
Wouter
  • 225
3
votes
1 answer

Replicate pseudocode format

I have to include algorithms in a paper and they must appear as follows: [A] X ← X-1 Y ← Y+1 IF X ≠ 0 GOTO A so I am trying to replicate this exactly, exploring some new packages as well but unfortunately it seems I can't get…
haunted85
  • 1,295
3
votes
0 answers

Adding a 'break' command to algpseudocode pseudocode

I want to add a \Break command to algpseudocode, which will display the word 'break' in the same font as 'return' is displayed. I've read the algpseudocode manual, but it only seems to explain how to define custom blocks, rather than individual…
Koz Ross
  • 841
  • 2
  • 11
  • 14
3
votes
1 answer

Formatting - Algorithm

I have following pseudocode: I want to write it as an algorithm but not able to format it properly. Following is my attempt: \documentclass{article} \usepackage{algorithm,amsmath,algpseudocode} \begin{document} \begin{algorithm} …
learner
  • 251
3
votes
1 answer

Pseudocode in LaTeX

\documentclass{article} \usepackage{amsmath} \usepackage[noend]{algpseudocode} \usepackage{algorithm} \makeatletter \def\BState{\State\hskip-\ALG@thistlm} `\makeatother \begin{document} \begin{algorithm} \caption{AIP}\label{euclid} \begin{algorithm…
3
votes
1 answer

pseudocode: functions within nested frames

I want to render my algorithm in a way, that the reader can see the functions within an extra frame like this: For writing the pseudocode I would prefer the algorithmicx package. Any advice is greatly appreciated.
3
votes
1 answer

Switch statement in LaTeX using package pseudocode

I am using \usepackage{pseudocode} in LaTeX for writing pseudocode. How to write switch statement using this package? I write more 90% pseudocode using the package pseudocode. In function Validate i want to write switch Statement.…
mridul
  • 131
2
votes
1 answer

Pseudocode in the style of Algorithm Design (Kleinberg & Tardos)

How do you write pseudocode in the style below? I tried using the verbatim environment but I can't seem to get the variables italicized and symbols like \in to work. I also tried using the algorithmic and algorithm2e packages but they seem much more…
nvi
  • 23
2
votes
2 answers

How to remove whitespace in pseudocode

I have this type of figure containing pseudocode and my result is like shown here: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{cryptocode} \usepackage{dashbox} \begin{document} \begin{figure}[h] \centering \fbox{% …
jonnyx
  • 123
2
votes
2 answers

Change name in pseudocode

I am writing my code in pseudocode package and I would need to change the name "Algorithm" to "Algoritmus". Is there any possibility how to do this in this package? I have found it just for package algorithm, but I have everything written and I…
Lucie
  • 23
2
votes
1 answer

Beginner: problems with algorithmic, some commands not available?

I am a real beginner in latex, and now I am struggling with using the algorithm package and algpseudocode to write some code. What I did until now is: \usepackage{algorithm} \usepackage{algpseudocode} \begin{algorithm} \caption{My algorithm doing…
Fiona
  • 21
1
vote
1 answer

How do I create an aligned column of text before the numbers in a "pseudo" environment?

I want to create a "diff" effect using the pseudo package, inspired by GitHub/Gerrit diffs. However, the symbols at the start of the line aren't lined up - they move when the digits go from 9 to 10. How can I get this to look nice? Can I force the…
1
vote
1 answer

Disable algorithmic line numbers with IEEE template

I want to disable line number in pseudo-code blocks, even though there isn't 1 in the \begin block. I am using the IEEE template This is the code \begin{algorithm} \caption{Test} \begin{algorithmic} \State $test$ \State $test$ \State…
1
2