Quick Index
Purpose
We learned that an algorithm is a well defined set of instructions (steps) for doing a task. And we learned how to write algorithms in human language. Another approach is to write algorithms in pseudocode. We define pseudocode as:
- Plain language steps for an algorithm written in "almost-code". It is intended for human reading unlike computer program code which is intended for machine reading.
Pseudocode enhances problem solving (algorithm writing) by being simple and concise. It's main purposes are:
- The primary purpose of pseudocode is to "convey logical ideas" in a somewhat human-like language, and to facilitate "uninhibited problem solving"
- A secondary purpose is that it aims to be "almost" (pseudo) program code. This makes the translation to program code easier.
In other words, pseudocode is the best of both worlds:
- Understandable by humans (most important).
- And almost understandable by machines (thus easier translation to program code)
Note that pseudocode is not intended for machine reading, but rather is meant for relatively easy translation to program code (that can be read by machines).
Pseudocode Advantages
- More concise than human languages
- Significantly simpler than most programming languages (a smaller set of syntax rules) -- thus allows focus on problem solving
- Does not require time spent finding and fixing syntax errors. As long as the logic conveys the idea -- it is golden.
- Easier (vs human language) to translate to program code
A two-phase approach to algorithms can be helpful:
- Write general steps in human language
- Write detailed step-by-step instructions in pseudocode
Writing Program Code
Pseudocode is used as a blueprint to write program code.
The translation is relatively straightforward -- the work involves adding the specific language syntax (rules).
We will find out that our pseudocode can be used basically "as-is" in a web browser on our machines (no installs needed). We will soon leverage this fact to test (and play) with our algorithms.