StudyVault
Home Unit Overview Exam Technique Revision Techniques ← Previous Lesson Next Lesson →

← Back to Dashboard

Overlay:
0:00 / 0:00 Narration generated using AI text-to-speech.

Defining Algorithms: Pseudocode and Flowcharts

What Is an Algorithm?

An algorithm is a precise, step-by-step set of instructions for solving a problem. Every program you have ever run began as an algorithm. Before any code is written, a programmer must first design the logical steps the computer needs to follow. Getting those steps right — in the right order, with the right decisions — is the foundation of good software.

Algorithms are not the same as programs. A program is a specific implementation in a specific language. An algorithm is language-independent — the same logic can be expressed in pseudocode, as a flowchart, or as code in Python, Java or any other language. Your exam tests whether you can design, trace and evaluate algorithms, regardless of which language you prefer to code in.

Key Fact

A good algorithm must be unambiguous (each step has exactly one interpretation), finite (it must eventually stop), and effective (it must actually solve the problem it was designed for).

Pseudocode

Pseudocode is an informal notation that sits halfway between plain English and a real programming language. It is precise enough to be translated directly into code, but readable enough that a non-programmer can follow the logic. Your exam uses a set of specific pseudocode conventions — learn them so your algorithms are unambiguous.

The key pseudocode keywords you need are shown below. The exam paper prints them in lower case, and it ends a while loop with the word repeat. Capitals in your own answers are fine, as long as the logic is clear:

PurposePseudocode keywordExample
Assignmentsetset total = 0
Output to screenoutputoutput “Hello”
Input from userinputinput name
Set a data typeismyvariable is integer
Conditionalif / else / end ifif score > 50
Count-controlled loopfor / nextfor i = 1 to 10 ... next i
Condition-controlled loopwhile / repeatwhile total < 100 ... repeat
Post-condition looprepeat / untilrepeat ... until done = TRUE
Define a subroutineDeclare / End SubroutineDeclare Greet ... End Subroutine
Call a subroutinecallcall Greet

Below is a complete pseudocode algorithm that asks the user for three numbers and outputs their average. Each line maps directly to a keyword in the table above.

INPUT num1
INPUT num2
INPUT num3
SET total = num1 + num2 + num3
SET average = total / 3
OUTPUT “The average is ” & average

Notice: INPUT handles input, SET handles assignment, and OUTPUT sends text to the screen. The & operator joins (concatenates) a string and a number in the output.

Flowcharts

A flowchart shows exactly the same logic as pseudocode but as a visual diagram. Each shape has a fixed meaning. Arrows show the flow of control — which instruction comes next. You need to know five shapes:

ShapeNameUsed for
Oval / rounded rectangleTerminatorSTART and STOP of the algorithm
RectangleProcessAny calculation, assignment or output step
ParallelogramInput / OutputReceiving data from the user or displaying a result
DiamondDecisionA yes/no question — branches the flow
Rectangle with double side barsSubroutine callCalling a named subroutine or function
Key Fact

Every flowchart must start and end with a terminator (oval). Decision diamonds always have exactly two exit arrows, typically labelled “Yes” and “No”. Process boxes have one entry and one exit arrow.

Many students write Python or JavaScript instead of pseudocode when the exam asks for an algorithm. Real code can score, but there are two risks. First, a syntax slip in Python can hide your logic, and a marker can only credit logic they can follow. Second, pseudocode is faster to write in exam conditions because you don’t worry about syntax errors.

Another common error is writing prose instead of pseudocode: “Ask the user for a number, add it to the total, and repeat.” This is not pseudocode — it has no control structure keywords and cannot be traced step by step. Always use the keywords: INPUT, SET, FOR, WHILE, IF.

Trace Tables

A trace table is used to check an algorithm by simulating it line by line. You create a column for every variable, plus an output column. Then you work through the algorithm and record the value of each variable after each step. Trace-table questions are a regular feature of the written exam — many students give only the final answer and lose intermediate marks.

Consider this algorithm:

SET total = 0
FOR i = 1 TO 3
  SET total = total + i
NEXT i
OUTPUT total

Trace table:

LineitotalOutput
SET total = 0—0
i = 1, total = 0 + 111
i = 2, total = 1 + 223
i = 3, total = 3 + 336
OUTPUT total6

The answer is 6. Fill in every row — marks are awarded per row, not just for the final output.

Practice Questions

Test yourself on this lesson. Pick a question, write your answer, then get it marked.

AI feedback
AI feedback is guidance, not a final exam mark. If you disagree, your teacher's view is always the tie-breaker.
← Back to unit
Video

© 2026 StudyVault · About · FAQ · Copyright & IP · Privacy · Disclaimers

StudyVault Education Ltd · registered in England and Wales, company no. 17490559 · 71–75 Shelton Street, London WC2H 9JQ