πŸ“š Knowledge Library β€” Topic 7.6 β€” Algorithm Design & Problem Solving

Pseudocode Explained Simply

Learn how an algorithm is written as clear, readable steps that can later be translated into a programming language.

1. Invitation

Pseudocode is an algorithm written in readable steps.

Pseudocode is a way of writing an algorithm using code-like statements that are easy for people to understand.

It is not tied to one programming language, so the same pseudocode can later be translated into Python, Java or another language.

πŸ’‘ Key idea: pseudocode explains the logic without worrying about exact programming syntax.
Figure 1.1
From Idea to Code
Problem
↓
Algorithm
↓
Pseudocode
↓
Program code
2. Big Idea

The logic matters more than perfect syntax.

Pseudocode should be clear, consistent and easy to translate into a real program.

Commands such as INPUT, OUTPUT, IF, FOR and WHILE make the structure of the algorithm obvious.

πŸ’‘ Pseudocode is precise enough to follow, but flexible enough to read.
Figure 2.1
Readable Logic
Clear keywords
Logical order
Meaningful names
Consistent layout
3. FutureLogic Bridge

Think of a recipe written for any kitchen.

A recipe says what to doβ€”mix, heat, stir and serveβ€”without depending on one brand of oven.

Pseudocode works in the same way. It describes the steps of the algorithm without depending on one programming language.

πŸ’‘ Bridge: pseudocode is a recipe for a program.
Figure 3.1
The Recipe Bridge
Ingredients
↓
Instructions
↓
Finished dish
4. Input and Output

INPUT receives data. OUTPUT displays data.

Use INPUT when a value enters the algorithm and OUTPUT when information is shown.

ExampleInput and output
OUTPUT "Enter your name"
INPUT Name
OUTPUT "Hello ", Name
πŸ’‘ Messages make inputs and outputs easier for the user to understand.
Figure 4.1
Data Movement
User
↓
INPUT
↓
Algorithm
↓
OUTPUT
5. Assignment

Assignment stores a value in a variable.

The assignment arrow ← means β€œstore the value on the right in the variable on the left.”

ExampleAssignment
Total ← Number1 + Number2
Count ← Count + 1
πŸ’‘ Read it from right to left: calculate first, then store the result.
Figure 5.1
Store the Result
Number1 + Number2
↓
Total
6. Selection

IF chooses between different routes.

Selection checks a condition and chooses what to do next.

ExampleIF statement
IF Mark >= 50
  THEN
    OUTPUT "Pass"
  ELSE
    OUTPUT "Try again"
ENDIF
πŸ’‘ IF asks the question. THEN and ELSE describe the two possible actions.
Figure 6.1
Two Routes
Condition?
↙ Yes    No β†˜
Action A    Action B
7. Iteration

Loops repeat instructions.

FOR loop

Used when the number of repetitions is known.

FOR Count ← 1 TO 10
  OUTPUT Count
NEXT Count

WHILE loop

Checks the condition before the loop body.

WHILE Number <> 0 DO
  INPUT Number
ENDWHILE

REPEAT loop

Checks the condition after the loop body.

REPEAT
  INPUT Password
UNTIL Password = "Open"

Which one?

Choose the loop that matches how the repetition should stop.

Count known = FOR
Check first = WHILE
Run once first = REPEAT
8. Flowchart to Pseudocode

The same algorithm can be represented in two ways.

A flowchart uses shapes and arrows. Pseudocode uses keywords and indentation.

Same algorithmAdd two numbers
INPUT Number1
INPUT Number2
Total ← Number1 + Number2
OUTPUT Total
πŸ’‘ Flowchart = visual sequence. Pseudocode = written sequence.
Figure 8.1
Two Representations
Flowchart
↔
Pseudocode

Same logic
9. Computational Thinking

Pseudocode makes the thinking visible.

SkillHow it appears
DecompositionEach sub-system can be written as a separate algorithm.
Pattern recognitionRepeated structures such as loops become easier to spot.
AbstractionOnly the important logic is written.
Algorithmic thinkingSteps are written in a precise order.
πŸ’‘ Pseudocode is where computational thinking becomes a written plan.
Figure 9.1
Written Thinking
Break down
↓
Choose logic
↓
Write steps
↓
Check order
10. Worked Example

Write pseudocode to find the larger of two numbers.

Worked exampleLargest value
OUTPUT "Enter the first number"
INPUT Number1

OUTPUT "Enter the second number"
INPUT Number2

IF Number1 > Number2
  THEN
    OUTPUT Number1
  ELSE
    OUTPUT Number2
ENDIF

How it works

The algorithm inputs two values, compares them and outputs the larger value.

Model answer: β€œThe IF statement compares Number1 with Number2. If Number1 is greater, it is output; otherwise Number2 is output.”
11. Exam Tip

Use the exact identifiers given in the question.

If the question gives an array or variable name, use it exactly. This shows that your algorithm is linked to the scenario.

🎯 Exam Tip: initialise totals and counters before a loop, perform the repeated work inside the loop, and output the final result after the loop.
Figure 11.1
Reliable Pattern
Initialise
↓
Loop
↓
Update
↓
Output
12. Common Mistake

Do not write vague instructions.

βœ— Too vague

β€œGet some numbers and work out the answer.”

βœ“ Clear pseudocode

INPUT Number1
INPUT Number2
Total ← Number1 + Number2

⚠️ Common Mistake: writing normal English instead of clear, code-like statements.
13. Another Common Mistake

Do not mix programming-language syntax into the answer.

Pseudocode should stay readable and consistent. Avoid adding Python colons, Java braces or language-specific commands unless the question asks for program code.

⚠️ Keep the logic clear: INPUT, OUTPUT, IF...THEN...ELSE...ENDIF and appropriate loops.
Figure 13.1
Stay Language-Independent
Pseudocode
β‰  Python only
β‰  Java only

Readable by all
14. Summary

Pseudocode in one screen.

Pseudocode is a readable, language-independent way of writing an algorithm.

INPUT receives data, OUTPUT displays data, assignment stores values, IF makes decisions and loops repeat instructions.

Clear indentation and meaningful identifiers make the logic easier to follow.

πŸ’‘ Final thought: write the logic clearly first; translate it into code later.
Figure 14.1
Final Model
INPUT
↓
PROCESS
↓
SELECT / REPEAT
↓
OUTPUT