Standards for pseudo code?

ferdystschenko picture ferdystschenko · Feb 20, 2010 · Viewed 22.3k times · Source

I need to translate some python and java routines into pseudo code for my master thesis but have trouble coming up with a syntax/style that is:

  • consistent
  • easy to understand
  • not too verbose
  • not too close to natural language
  • not too close to some concrete programming language.

How do you write pseudo code? Are there any standard recommendations?

Answer

Eli Bendersky picture Eli Bendersky · Feb 20, 2010

I recommend looking at the "Introduction to Algorithms" book (by Cormen, Leiserson and Rivest). I've always found its pseudo-code description of algorithms very clear and consistent.

An example:

DIJKSTRA(G, w, s)
1  INITIALIZE-SINGLE-SOURCE(G, s)
2  S ← Ø
3  Q ← V[G]
4  while Q ≠ Ø
5      do u ← EXTRACT-MIN(Q)
6         S ← S ∪{u}
7         for each vertex v ∈ Adj[u]
8             do RELAX(u, v, w)