Bounded Linear Operators Squared Norm
Terminology 1
Describing platform-independent and deeply technical code using natural language is referred to as pseudo code.
Description
Pseudo code is a representation that appears like code but is not actual code. It is used to illustrate algorithms without being constrained by any specific programming language. Pseudo code can utilize natural language as well as mathematical expressions, and as long as its definition is clear and not confusing, it can borrow syntax from specific programming languages.
How the algorithm is implemented may vary drastically based on the programmer’s style or various constraints, but the pseudo code should fundamentally represent the prototype of how the algorithm operates.
Ironically, while pseudo code is described as the ‘prototype of the algorithm,’ the way it is written itself offers various styles. Let’s examine two styles of pseudo code explaining selection sort. No matter the style of implementation, the fundamental principle is to perform sorting by repeatedly finding the minimum value.
Algorithm: Selection Sort 1 | ||
---|---|---|
In | An array of length | |
1. | for do | |
2. | ||
3. | # Swap elements | |
4. | end for | |
Out | An array sorted in ascending order |
This style is procedural, just like Fortran, C, or MATLAB. It often uses explicit keywords like end to close loops and conditional blocks, and accesses elements directly from an array level, making it easy to read.
Algorithm: Selection Sort 2 | ||
---|---|---|
In | An array of length | |
1. | # Initialize an empty array | |
2. | while | |
3. | ||
4. | ||
Out | An array sorted in ascending order |
This is an object-oriented style, like Python. Grammar is often borrowed from Python using indentation to delineate blocks, and if you’re reading a paper or textbook, unexpected data structures that are generally known might suddenly appear. The advantage is that it’s conceptually easier to understand than reading an index point by point.
A. Alhefdhi, H. K. Dam, H. Hata and A. Ghose, “Generating Pseudo-Code from Source Code Using Deep Learning,” 2018 25th Australasian Software Engineering Conference (ASWEC), Adelaide, SA, Australia, 2018, pp. 21-25, https://doi.org/10.1109/ASWEC.2018.00011 ↩︎