home

Pseudocode

Pseudocode provides an informal series of notations that describe ideas and operations. It is a high-level, loosely structured syntax intended to be intuitive for humans.

No broad or universal standard exists, but regardless of form, it’s intent is the same: to communicate the core structure of Algorithms at a higher level than a machine-readable implementation.

Symbolism

While a lot of syntax may use natural languages, some succinctness may be achieved through limited mathematical notation.

Operation Symbol
assignment or :=
comparison =, , <, >, ,
arithmetic +, , × /, mod
floor/ceiling ⌊...⌋, ⌈...⌉
logical AND, OR, NOT
sums, products Σ, Π

Control structures

As a set of personal conventions for these notes:

Example

An example expression of Insertion sort may appear as below:

INPUT: a₁, a₂, ..., aₙ as A

FOR i ← 2 to n
    j ← i
    WHILE j > 1 AND A[j-1] > A[j]
        swap A[j] and A[j-1]
        j ← j - 1