Learn
7.3.1 | EXPLAIN THE PURPOSE AND PROCESSES OF AN ALGORITHM
01 | READ FOR MEANING, NOT JUST KEYWORDS
You are shown an algorithm containing INPUT, IF and a loop. You recognise the instructions, but the question asks what the algorithm does. Naming its keywords is not enough.
Imagine watching someone prepare a sandwich. “They pick up bread, spread filling and put another slice on top” describes actions. “They make a sandwich” states the overall purpose. Both are useful descriptions, but they answer different questions.
In computing, the purpose is the task the algorithm accomplishes. Its processes are the operations and decisions used to accomplish that task.
This lesson connects the two. We will read small algorithms, follow their values and turn what we discover into clear explanations. You do not need to guess from the first variable name: there is evidence in the inputs, conditions, updates and outputs.
02 | PURPOSE AND PROCESS ANSWER DIFFERENT QUESTIONS
Suppose an algorithm inputs three scores, adds them and divides the total by three.
Its purpose is to calculate and display the average of three input scores. That is a concise description of the overall job.
Its processes include initialising a total, repeatedly receiving a score, adding it to the total, dividing the completed total by three and displaying the result.
“It uses a FOR loop” identifies a construct but not its job. “It repeats the score input and addition three times” explains the role of the loop in this algorithm.
A purpose statement should be specific enough to distinguish this task from other tasks. “It processes numbers” is too broad: calculating a total, finding a maximum and counting values above a threshold all process numbers differently.
03 | BEGIN WITH INPUTS AND OUTPUTS
Before tracing every line, look at what information the algorithm receives and what it produces. These give you a starting point.
An algorithm that inputs a price and quantity and outputs their product may calculate an item cost. An algorithm that inputs several scores and outputs a count may count scores meeting a condition rather than calculate their average.
Now inspect the processing to confirm the idea. A label saying “Average” is a clue, but if the algorithm only adds values and never divides, the label does not prove that an average has been calculated.
When a task lacks a stated real-world context, describe what can be established from the instructions. “Counts how many of five input values are at least ten” is accurate without inventing that the values must be exam marks.
Your explanation should describe the algorithm given, even if it appears to contain an error, rather than silently replacing it with the algorithm you think was intended.
04 | WORKED EXAMPLE: AVERAGE OF THREE SCORES
Read the complete algorithm below. Assume the three inputs are valid whole-number scores.
DECLARE Score : INTEGER
DECLARE Total : INTEGER
DECLARE Index : INTEGER
DECLARE Average : REAL
Total ← 0
FOR Index ← 1 TO 3
INPUT Score
Total ← Total + Score
NEXT Index
Average ← Total / 3
OUTPUT AverageTotal starts at zero. The FOR loop repeats three times, receiving one score and adding it to Total each time. After the loop, the algorithm divides Total by three and outputs Average.
The purpose is: calculate and output the average of three input scores.
The loop itself is a process within that purpose. It collects and accumulates the three values. The division after the loop uses the completed total.
Declarations introduce names and types; they do not set Total to zero. The separate assignment provides the starting value needed for accumulation.
05 | USE A TRACE TO SUPPORT YOUR INTERPRETATION
Try input scores 4, 7 and 10. A trace follows the instructions using chosen values, recording changes as they occur.
| Stage | Score | Total |
|---|---|---|
| Before loop | None | 0 |
| First repetition | 4 | 4 |
| Second repetition | 7 | 11 |
| Third repetition | 10 | 21 |
Total becomes 21, then Average becomes 7. This supports the explanation that the algorithm calculates an average.
One trace illustrates behaviour; it is not a complete proof for every possible input. Read the control structures too. The loop always receives three values in this example, and division occurs after all three have been added.
If the inputs were 2, 2 and 2, the average would be 2 rather than the total 6. Choosing values that distinguish possible interpretations can help you check whether an algorithm totals, averages or counts.
06 | NOTICE WHETHER IT TOTALS OR COUNTS
Two algorithms can look similar because both begin at zero and use a loop. Look closely at what gets added.
Total ← Total + Value adds the input value itself. Count ← Count + 1 increases a count by one. These produce different information.
With inputs 4, 7 and 10, a total is 21. A count of the number of inputs is 3. A count of values at least 5 is 2.
Do not describe every repeated addition as “counting”. Explain the update precisely and inspect whether a condition controls it. The value on the right-hand side reveals what accumulates.
Useful questions are: what starts at zero, what is added, how often is it added and under what condition? The answers often reveal the main process.
07 | WORKED EXAMPLE: COUNT VALUES MEETING A CONDITION
This algorithm receives five whole-number values. Its variable names are deliberately brief so you must read the operations rather than rely on descriptive labels.
DECLARE N : INTEGER
DECLARE C : INTEGER
DECLARE I : INTEGER
C ← 0
FOR I ← 1 TO 5
INPUT N
IF N >= 10
THEN
C ← C + 1
ENDIF
NEXT I
OUTPUT CC starts at zero. For each input N, the condition checks whether N is at least 10. C increases only if that condition is true. Finally, the algorithm outputs C.
The purpose is: count and output how many of five input values are at least ten. It does not calculate their sum, output all the values or reject values below ten.
A value below ten is still an input processed by the algorithm. It simply does not increase the count. Do not call this validation unless the algorithm actually checks acceptability and handles invalid input in that way.
08 | EXPLAIN A CONDITIONAL UPDATE
Use inputs 8, 10, 12, 3 and 10. The condition is false for 8 and 3, so C remains unchanged at those steps. It is true for both occurrences of 10 and for 12.
| Input N | N >= 10? | C after check |
|---|---|---|
| 8 | False | 0 |
| 10 | True | 1 |
| 12 | True | 2 |
| 3 | False | 2 |
| 10 | True | 3 |
The final output is 3. Equality matters: the condition uses >=, so values exactly equal to ten are counted.
A weak description is “It checks N and changes C.” A useful explanation is “It compares each input with ten and adds one to the count only when the value is at least ten.”
For an explain response, add the relationship: “C starts at zero because no qualifying inputs have been processed yet; each qualifying value increases C by one, therefore the final C represents the number that meet the condition.”
09 | WORKED EXAMPLE: FIND THE LARGEST VALUE
Now inspect a different update rule. Assume all three inputs are whole numbers; they may be positive, zero or negative.
DECLARE Value : INTEGER
DECLARE Largest : INTEGER
DECLARE Index : INTEGER
INPUT Largest
FOR Index ← 1 TO 2
INPUT Value
IF Value > Largest
THEN
Largest ← Value
ENDIF
NEXT Index
OUTPUT LargestThe first input is stored in Largest. The next two inputs are each compared with the current Largest. When a new value is greater, it replaces Largest. Otherwise Largest stays unchanged.
The purpose is: find and output the largest of three input values. The algorithm does not sort the values or retain all three in order.
Starting with a real input is important here. If Largest began at zero and all inputs were negative, zero might be output even though it was never entered. Using the first input gives a valid initial candidate.
10 | FOLLOW HOW THE LARGEST VALUE CHANGES
Take inputs −6, −2 and −8. Largest first becomes −6. The comparison −2 > −6 is true, so Largest becomes −2. The comparison −8 > −2 is false, so it remains −2.
The output is −2, the largest of those three negative numbers. “Largest” means greatest numeric value, not the value with the largest digits when the sign is ignored.
With inputs 7, 7 and 3, the second value does not replace Largest because 7 > 7 is false. This does not prevent the algorithm finding the largest value: it remains 7.
Notice that two repetitions follow the first input. The algorithm receives three values altogether, not two. Count inputs across the whole algorithm rather than looking only at the loop bounds.
11 | DISTINGUISH VALIDATION FROM SELECTION
Consider this input loop.
DECLARE Score : INTEGER
REPEAT
INPUT Score
UNTIL Score >= 0 AND Score <= 10
OUTPUT ScoreThe user is asked again until Score lies between zero and ten inclusive. The purpose of this fragment is to obtain a score within the permitted range, assuming numeric whole-number input.
With inputs −1, 12 and 8, the first two checks are false and repetition continues. At 8, both comparisons are true, so the loop ends and 8 is output.
This differs from the five-value counting algorithm. There, every value is received once and only some increase a count. Here, an unacceptable value causes another input within the same task.
Do not infer “the input must be correct” from validation. A number can be within range but still be the wrong score for a particular student. Explain the specific check the algorithm performs.
12 | TURN YOUR FINDINGS INTO A CLEAR ANSWER
For a purpose question, begin with a concise overall action: calculate an average, count qualifying values, find a maximum or obtain a value within a range. Include the number of inputs or condition when it helps identify the task.
For a process question, explain the main stages: initialisation, input, repetition, decisions, updates and output. Connect each stage to its role rather than translating every line mechanically.
| Weak answer | More precise answer |
|---|---|
| It uses a loop. | It receives five values and checks each against ten. |
| It adds numbers. | It adds one to C only for inputs at least ten. |
| It outputs C. | It outputs the number of input values that met the condition. |
| It sorts the numbers. | It retains and outputs the largest of three values; it does not sort them. |
A good explanation is supported by the given instructions. Use exact limits: “at least ten” differs from “greater than ten”, and “three inputs” differs from “inputs until the user stops”.
You can use connectives such as because, therefore and resulting in to show how the steps contribute to the purpose. Avoid invented context or claims that the algorithm does more than its instructions show.
13 | CHECK YOUR INTERPRETATION WITH CONTRASTING DATA
If two possible purposes seem plausible, choose data that would produce different results. For inputs 2, 4 and 9, a total is 15, an average is 5, a maximum is 9 and a count of values at least 5 is 1.
Trace the algorithm and compare the result with those possibilities. Then confirm the reason in the instructions: adding values, dividing a total, replacing a maximum or increasing a count.
Also examine important edge cases. Values exactly at a threshold reveal whether equality is included. Negative values reveal whether maximum initialisation is sensible. A valid first input shows whether a post-condition loop still runs once.
This is a way to investigate meaning, not a replacement for carefully reading every relevant step. A single output can coincidentally fit several purposes if your chosen values are unhelpful.
14 | A RELIABLE READING ROUTINE
Start by identifying inputs and outputs. Next, find the initial values and the variables that change. Inspect the conditions and loop bounds to see when updates happen and how many values are processed.
Dry-run a small example. Record the values after each important update and follow execution until the algorithm finishes. Then state the overall purpose and explain the processes that support it.
If the algorithm contains a fault, describe its actual behaviour and identify the cause when asked. For example, resetting a total inside a loop discards earlier additions; you should not describe it as correctly totalling all inputs.
The key skill is connecting instructions to meaning. Once you can explain why a count changes or why a maximum is replaced, unfamiliar variable names become much less intimidating.