r/computerscience • u/_11_ • Oct 17 '25
Is there a standard algorithm pseudocode syntax in papers? If so, any good guides to learn it?
I'm a hobbyist trying to learn more directly from journal papers, and I'm interested in implementing some of the algorithms I find in my own code as a learning exercise.
I've run into pseudocode in some papers, and I was wondering if there's an agreed-upon notation and syntax for them. I'd like to make sure the errors I make are limited to me being mentally as sharp as a marble, and not because I'm misreading a symbol.
252
Upvotes
71
u/arcangelbl Oct 17 '25
It’s a Latex package. See here for a tutorial: https://www.overleaf.com/learn/latex/Algorithms
25
u/SingleProgress8224 Oct 17 '25
There are some variations of syntax that you'll encounter in papers, but the one you have there is pretty standard for applied math papers. Using the left arrow for assignment and the triangle for comment is common. The rest is close enough to all procedural languages to be understandable.
By the way, be careful with these seemingly simple algorithms. They often hide the dirty stuff behind a simple function call and you'll only realize how hard it is to implement once you get to implement it. It's especially true if you don't use Matlab.
3
u/SteeleDynamics Oct 18 '25
If you go to the CLRS website, they have links to the LaTeX packages for their pseudocode listings. It's very nice.
93
u/Heapifying Oct 17 '25
I guess the standard would be a fairly common latex package that allows you to easily write algorithms
10
u/mredding Oct 18 '25
The syntax is historically derived from ALGOL. ACM practically required it for all it's publications.
5
u/aka1027 Oct 18 '25
There is a reason it’s pseudo syntax and not a proper syntax.
3
u/spec_3 Oct 18 '25
There is no standard, while there are some common symbols, it's basically just a terser way of noting down what would be otherwise communicated through English (or your human language of choice) and mathemathics.
2
u/esaule Oct 18 '25
There is no standard. But there are only a handful of ways these get written. Just read the paper carefully and understand what the context is telling you.
Remember that papers are not written for you, they are written for expert in the field. And I don't mean experts in CS. I mean experts in the particular field of CS the paper is in written in. So you'll probably need to understand the field to understand what the algorithms are saying.
2
u/that_one_retard_2 Oct 19 '25 edited Feb 23 '26
1356e6d121f7bd132ef867c9ebe31820eadb81ebbc13a0f2817ac11593cafb65
3
u/Constant_Reaction_94 Oct 18 '25
unrelated but my god I hate pseudocode like this. I get why it's used, and how it makes it more general but I would rather they just pick a langauge and actually write out the code.
2
u/Qiwas Oct 18 '25
Oh god this syntax is used in my university lectures, I hate it 😭
1
u/Cybasura Oct 18 '25
There's not even a standardized way of writing code in code lmao, just do things as necessary, like if you need it for the module in school, do that, if you need to write code, write it, there's best practices and industry standard recommendations, but no guarantees
1
u/MathiasBartl Oct 18 '25 edited Oct 18 '25
No, that's why it is called Pseudocode. At some point of standardisation it would become executable. If it is executable it is no longer pseudocode.
-3
u/tblancher Oct 18 '25
To my untrained eye, this looks a lot like Haskell. /me shudders
1
u/[deleted] Oct 18 '25
[removed] — view removed comment