Problem Solving, Algorithms and Flowcharts
What the examiner tests
Writing an algorithm in steps, drawing or reading a flowchart, and dry-running a small logic problem.
Core rules
- An algorithm must be finite (ends after a fixed number of steps), definite (each step is unambiguous), effective, and must take input and produce output.
- Flowchart symbols: oval = Start/Stop; parallelogram = input/output; rectangle = process/assignment; diamond = decision (one entry, two exits - Yes/No); arrow = flow; circle = connector; document = printed report.
- Every flowchart has exactly one Start and at least one Stop, and all paths must reach a Stop.
- Standard patterns: sequence; selection (if/else, nested); iteration (loop with initialisation, condition and update).
- Dry running means making a trace table of variable values after each step.
Worked example
Largest of three numbers A, B, C:
- Start.
- Read A, B, C.
- Set MAX = A.
- If B > MAX, set MAX = B.
- If C > MAX, set MAX = C.
- Print MAX.
- Stop. Trace with A = 3, B = 7, C = 5: MAX becomes 3, then 7, then stays 7. Output is 7. Notice that each new number is compared with the running maximum, so the same idea extends to any count if placed inside a loop.
Traps
- Using a rectangle for a decision or a diamond for an assignment.
- Forgetting to initialise MAX, SUM or a counter before a loop.
- Omitting the increment inside a loop, giving an infinite loop.
- Drawing two Start symbols or a branch that never reaches Stop.
- Writing an algorithm as C code when the question asks for step form.