Blueprint First: Designing Algorithms with Pseudocode and Flowcharts
Byte, a friendly blue robot, stands at a glowing whiteboard sketching numbered steps and diamond-shaped decision boxes connected by arrows, a closed laptop resting beside the board.
- Define an algorithm by naming all five Knuth properties: finiteness, definiteness, input, output, and effectiveness.
- Translate a plain-language problem into structured pseudocode using sequence, selection, and iteration control structures.
- Represent the same algorithm as a flowchart using start/end, input/output, process, decision, and arrow symbols.
- Explain why designing language-independently before coding reduces errors and aids collaboration.
Key terms
- Algorithm
- A finite, unambiguous sequence of effective steps that solves a problem.
- Pseudocode
- Structured plain-language description of logic that mimics code without any language's strict syntax.
- Definiteness
- The Knuth property that every step is precisely and unambiguously specified for execution.
- Selection
- A control structure that chooses among branches based on a tested condition.
- Iteration
- A control structure that repeats steps while a stopping condition has not been met.
The Three Control Structures
Every algorithm, no matter how complex, is built from just three control structures, a result formalized by the structured-programming theorem. Sequence runs steps in written order; selection chooses one branch based on a condition; iteration repeats a block until a condition changes. Mastering these three lets you express any computable procedure without arbitrary jumps. Pseudocode names them with keywords like IF/THEN/ELSE and WHILE/FOR so a reader can map the design directly onto code in Python, Java, or any imperative language.
Flowcharts and ISO Symbols
Flowcharts encode the same logic visually using standardized symbols (ISO 5807). An oval marks start and end, a parallelogram marks input or output, a rectangle marks a process or assignment, and a diamond marks a decision with labeled Yes and No branches. Arrows show the direction of control flow. Because the symbols are agreed conventions, a flowchart drawn by one engineer is readable by another, making it a shared design language that surfaces missing branches, unreachable steps, and loops with no exit before any code is written.
Worked examples
Design pseudocode that finds the largest of three numbers a, b, and c.
- INPUT a, b, c from the user.
- SET largest = a as the initial assumption.
- IF b > largest THEN SET largest = b, comparing the second value.
- IF c > largest THEN SET largest = c, comparing the third value.
- OUTPUT largest, which now holds the maximum of the three.
Answer: largest holds the greatest of a, b, and c after two comparisons against a running maximum.
Activity
Put these pseudocode steps in the correct order to find the largest of three numbers
Practice
Write pseudocode that reads a number and prints whether it is even or odd.
Draw a flowchart for a loop that prints the numbers 1 through 5 in order.
Common mistakes to avoid
- Pseudocode runs on a computerPseudocode is a non-executable design tool that no compiler or interpreter can directly run.
- An algorithm needs only three propertiesKnuth requires all five: finiteness, definiteness, input, output, and effectiveness together.
Check your understanding
Which list correctly names ALL FIVE properties that every algorithm must have according to Knuth's canonical definition?
In a standard flowchart, which symbol represents an INPUT or OUTPUT operation such as 'INPUT a, b, c'?
Why should you write pseudocode or draw a flowchart BEFORE writing real code?
Which pseudocode line correctly expresses ITERATION — a repeating loop?
Recap
An algorithm is a finite, definite, effective procedure with input and output, expressed language-independently through pseudocode or flowcharts built from sequence, selection, and iteration so logic errors surface cheaply before coding begins.
Reflect
When have you skipped planning and paid for it later in debugging time?