Skip to content
IGCSE·Tuition

Computer Science · Help with common difficulties

I cannot explain the algorithm without showing finished code

You can write the program, but when a question says explain, you freeze or copy the code line by line.

On this page
  1. Why does this feel so hard?
  2. A four-part frame
  3. Worked example
  4. Weak versus strong
  5. The mistake to watch for
  6. How to practise
  7. Self-check
  8. Where to go next

To explain an algorithm, say what it is for, what it works on, what it does at each step and why. The code is one way to write it. The explanation is about the idea, and it should make sense to someone who cannot see the code.

This is a reasoning skill that runs through problem-solving explanations and algorithm design. The lesson explain an algorithm independently of a programming language works on this idea directly.

Why does this feel so hard?

When you write code, each line has a fixed meaning and the computer does the rest. When you explain, you must choose the words yourself, and two traps appear. One is to repeat the code in plain English, line for line. The other is to say something vague like “it checks everything”.

Both happen because the explanation has no frame. A simple frame fixes it.

A four-part frame

  1. Purpose: one sentence on what the algorithm finds or does.
  2. Input and output: what goes in, what comes out.
  3. Steps in words: two to four sentences, in order, each saying what happens to the data.
  4. Reason or check: why it works, or a trace with sample values.

Worked example

The algorithm finds the highest mark in a list of marks. Sample list: 14, 9, 21, 17.

Purpose. It finds the largest mark in a list.

Input and output. The input is a list of whole numbers with at least one item. The output is the largest value in the list.

Steps in words. The algorithm starts by treating the first mark as the largest seen so far. It then looks at each remaining mark in turn. Whenever a mark is larger than the largest so far, that mark becomes the new largest. After the last mark, the stored value is the answer.

Trace with the sample list.

Mark looked atLargest so far after this mark
14 (first)14
914 (9 is not larger)
2121 (21 is larger)
1721 (17 is not larger)

The output is 21.

Reason. The stored value is always the largest among the marks looked at so far, so at the end it is the largest of the whole list.

Weak versus strong

Weak explanation: “It has a loop. It uses an if statement to compare. Then it prints the variable.”

This names code features but says nothing about the marks, and gives no reason why the answer is the largest. A reader still does not know what the algorithm achieves.

Strong explanation: “It starts with the first mark as the largest so far, then checks each other mark in turn. If a mark is larger, it replaces the stored largest. At the end the stored value is the largest mark, because it was updated every time a bigger mark appeared.”

It says what happens to the data, in order, and gives the reason.

The mistake to watch for

Mistake: describing code features instead of behaviour. Words like loop, variable and if statement belong in a code answer. An explanation question wants what happens to the data.

Correction: for each sentence, ask “what happens to the marks here?” If the sentence could be about any program, it is too vague. Add the data and the action.

How to practise

  1. Take an algorithm you have already written.
  2. Close the code and write the four-part frame from memory.
  3. Trace it with a small list to confirm your words are true.
  4. Swap in a different sample list and check the explanation still holds.

The pseudocode trace trainer shows the stepping on small original algorithms, and the Python reasoning sandbox lets you test an idea quickly so the explanation describes something that really works.

Self-check

1. Write a one-sentence purpose for an algorithm that counts how many marks in a list are at least 50.

Show answer"It counts how many marks in a list are 50 or more." A good answer names the data (marks), the condition (at least 50) and the result (a count).

2. Which is a stronger step: “it goes round a loop” or “it looks at each mark in turn and compares it with the largest so far”?

Show answerThe second. It says what happens to the data at each step. "Goes round a loop" names a code feature without saying what it does.

3. Using the sample list 14, 9, 21, 17, what is the stored largest after the third mark is looked at?

Show answer21. The first mark sets it to 14, the second (9) leaves it at 14, and the third (21) is larger, so the stored value becomes 21.

Where to go next

Work on describing a correction rather than merely showing code and connecting a trace with the final output. For the algorithm-design side, read trace a sequence with a state table.

When you are ready to have someone listen to your explanations and tighten the wording, online one-to-one Computer Science tuition starts with a paid trial lesson from RM80.

Questions people ask

What does a good explanation of an algorithm include?

The purpose, what goes in, what comes out, the main steps in plain words, and the reason each step is there. A short trace with sample values shows the explanation is true. It does not need code syntax.

Is reading the code aloud a valid explanation?

Usually not. Repeating each line says what the code is, not what it achieves. A good explanation says what the step does to the data and why, so a reader who has never seen the code could follow it.

How long should an explanation be?

As long as the marks or the instruction suggest, and no longer. Give the main idea first in one sentence, then two or three precise steps. Extra detail that is not about the algorithm earns nothing.

Can a trace table count as an explanation?

It supports one. A trace shows what happens with sample values, but the question usually wants the idea stated in words as well. Use the trace to back up a sentence, for example by showing where the largest value changes.

Updated:

Your next step

If your code works but your explanations stall, a one-to-one teacher can listen to you explain a fresh algorithm aloud and help you find the sentence that each step needs.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

9,000+ students helped through our service