IGCSE Computer Science · Area 2 · Algorithms, programming and logic

Algorithm design and problem-solving

An algorithm is a set of steps that solves a problem, and this topic is about designing those steps before anyone writes a line of code. You need the four stages of the program development life cycle, how a large problem is decomposed into sub-problems, how a solution is shown in pseudocode or as a flowchart, how validation and verification keep bad data out, and how a trace table records a dry run. Marks here are lost through imprecise wording and half-finished trace tables far more often than through not knowing the theory.

Not started

Syllabus coverage

  • Understand the program development life cycle, limited to analysis, design, coding and testing
  • Understand that every computer system is made up of sub-systems, which are made up of further sub-systems
  • Understand how a problem can be decomposed into its component parts
  • Use different methods to design and construct a solution to a problem, including structure diagrams, flowcharts and pseudocode
  • Explain the purpose of a given algorithm, by stating its purpose and describing the processes involved
  • Identify the inputs, processes, outputs and storage of a problem
  • Understand standard methods of solution, limited to linear search, bubble sort, totalling, counting and finding maximum, minimum and average values
  • Understand the need for validation checks on input data: range check, length check, type check, presence check, format check and check digit
  • Understand the need for verification checks on input data: visual check and double entry check
  • Suggest and apply suitable test data, limited to normal, abnormal, extreme and boundary data
  • Complete a trace table to document a dry run of an algorithm
  • Identify errors in given algorithms and suggest ways of correcting them
  • Write and amend algorithms for given problems or scenarios using pseudocode, program code and flowcharts, with precision at each step

Part of the IGCSE Computer Science syllabus 0478.

Algorithm design: the building blocksEvery algorithm is sequence, selection and iteration combined - there is nothing else.A flowchart's shapes are not decoration: each one tells you what kind of step it is.The three constructsevery algorithm is built from theseSequenceone step after anotherSelectionchoose a path: IF ... THEN ... ELSEIterationrepeat: FOR ... NEXT, WHILE ... DOFlowchart symbolsthe shape tells you what the step doesTerminatorstart or stopProcessa step or calculationDecisiona question with two exitsInput / outputread or writeDecomposition breaks a problem into smaller problems; abstraction removes the detail that does not matter for the solution.An algorithm is the solution written out in full, before anyone writes it in a programming language.
The six standard flowchart symbols, with a small flowchart beside them showing sequence, selection and iteration, and a trace table recording the values of the variables as the flowchart is dry-run.

What an algorithm is, and why the wording has to be precise

An algorithm is a sequence of steps that solves a problem. It does not have to be written in a programming language: a recipe, a set of directions and the instructions on a ticket machine are all algorithms. What makes something an algorithm is that the steps are in the right order, each step means only one thing, and the sequence finishes after a finite number of steps.

Every algorithm can be split into inputs, processes, outputs and storage. The inputs are the data the algorithm is given, the processes are the calculations and decisions it carries out, the outputs are the results it produces, and the storage is anything it has to hold on to while it is working. A school register algorithm takes each pupil's name as input, counts the present pupils as a process, prints a summary as output, and keeps a running total of the pupils marked present while it goes.

You may be asked to explain the purpose of a given algorithm, and that means two things. Stating the purpose is one sentence about what the whole algorithm achieves, such as 'it finds the largest number in a list'. Describing the processes means going through what the algorithm actually does, step by step: 'it sets the maximum to the first value, then compares every other value with the maximum and replaces it whenever it finds a larger one'.

Precision is required. Cambridge marks algorithms written in precise pseudocode, and x > y is acceptable where 'x is greater than y' is not. The same rule applies to the decision boxes of a flowchart: write the condition as an expression, not as a sentence. Use the conventions of the syllabus, with upper-case keywords such as DECLARE, INPUT and OUTPUT, and the assignment arrow ←.

  • State the purpose in one sentence, then describe the processes in the order the algorithm carries them out.
  • Name every variable the algorithm uses, every value it outputs and every point at which the user is prompted for input.
  • Write conditions as expressions: x > y is acceptable, x is greater than y is not.
Part of the algorithmWhat it meansExample from a school register program
InputsThe data the algorithm is given to work withThe name and the mark for each pupil on the register
ProcessesThe calculations and decisions the algorithm carries outAdding up the pupils present and comparing the total with the number on roll
OutputsThe results the algorithm producesA printed attendance summary for the form tutor
StorageThe values the algorithm has to keep while it is workingA running total of pupils marked present, held in a variable
Never write an algorithm as a set of English sentences. Use the pseudocode conventions in the syllabus, with upper-case keywords and ← for assignment, and indent every line that sits inside another statement.

Decomposition and abstraction: breaking a problem into sub-systems

Every computer system is made up of sub-systems, and each sub-system is made up of further sub-systems. A school's computer system has sub-systems for teaching, attendance and reporting. The attendance sub-system has its own sub-systems for registration, absence checking and letters home. Each level does one job properly and passes its result up to the level above, so a problem that looks impossible at the top becomes a set of small jobs at the bottom.

Decomposition is breaking a problem down into its component parts until each part is small enough to solve on its own. An online shop decomposes into a basket, a payment system and a delivery calculator, and the payment system decomposes further into card checking, address checking and order confirmation. Each part can then be designed, written and tested separately, and different programmers can work on different parts at the same time.

Abstraction is the other half of the job. It means removing the detail that does not matter for the problem in front of you and keeping only what does. A tube map is an abstraction of a railway network: it keeps the stations and the lines and throws away the real distances and the shape of the streets above them. In the same way, a program that works out a class average does not need to know a pupil's address or their shoe size.

Structure diagrams are the usual way to record decomposition on paper. The whole problem sits at the top, the main sub-problems sit underneath it, and each of those is broken down again. The diagram shows the whole solution at a glance, and each box can later become a procedure or a function in the finished program.

Design methodWhat it showsBest used for
Structure diagramThe problem at the top with its sub-problems underneath, broken down level by levelPlanning the overall solution and showing how the parts fit together
FlowchartThe steps of a solution as shapes joined by arrows, including the decisions and the loopsShowing the flow of control through a solution, especially where decisions are involved
PseudocodeThe steps of a solution written as precise statements, using the syllabus keywordsSetting out the detail of a solution so that it can be turned into program code
Decomposition and abstraction work as a pair. Decompose to split the problem into parts, then abstract each part to throw away everything that is not needed for it.

The program development life cycle: analysis, design, coding and testing

The program development life cycle has four stages, and Cambridge limits the examinable list to these: analysis, design, coding and testing. The stages run in order, but the cycle can be repeated: if testing uncovers a problem with the design, you go back and change the design.

In analysis you work out what the problem really is. That means abstracting the important details, decomposing the problem, and identifying the problem and its requirements: what the program must take in, what it must produce, and what it must do in between. Getting this stage wrong is expensive, because everything that follows depends on it.

In design you work out how the solution will be built, without writing the finished code. Decomposition carries on here, and the design is recorded as structure diagrams, flowcharts or pseudocode.

In coding you turn the design into program code and test it as you go. This is iterative testing: you check each procedure or function as soon as you write it, rather than waiting until the whole program is finished and trying to test everything at once.

In testing you run the finished program with planned test data and compare what it produces with what you expected. Testing is not proof that a program works; it is a search for errors, and the test data has to be chosen to try to make the program fail.

StageWhat you do at this stageWhat you produce
AnalysisAbstract the problem, decompose it, and identify the problem and its requirementsA clear statement of what the program must do, with its inputs, processes, outputs and storage
DesignDecompose further and decide how the solution will workStructure diagrams, flowcharts and pseudocode
CodingWrite the program code and test each part as it is written, which is iterative testingWorking, commented program code
TestingRun the program with planned test data and compare the results with the expected resultsA record of the tests carried out, the test data used and the results
Use the phrase iterative testing for the coding stage. Testing is not something that happens only at the end, and a question about the life cycle usually has a mark for saying so.

Sequence, selection and iteration, in pseudocode and in flowcharts

Sequence means the statements are carried out one after another, in the order they are written. It is the default, and the order matters: setting a total to 0 before a loop gives a correct total, while the same statement inside the loop wipes out the total on every pass.

Selection means the program chooses between different paths. An IF statement tests a condition and runs its statements only when the condition is true, with an optional ELSE clause for the other case. A CASE statement chooses between several branches depending on the value of one variable, and an OTHERWISE branch at the end catches anything that does not match.

Iteration means repeating statements, and there are three loops you must be able to tell apart. A count-controlled loop (FOR ... NEXT) repeats a known number of times. A pre-condition loop (WHILE ... DO ... ENDWHILE) tests its condition before the statements run, so it may run zero times. A post-condition loop (REPEAT ... UNTIL) tests its condition after the statements have run, so it always runs at least once.

In a flowchart the three constructs look different straight away. Sequence is a run of process boxes joined by arrows, selection is a diamond with two labelled exits, and iteration is a loop in which an arrow carries control back to a point earlier in the chart. There are six flowchart symbols you are expected to use, and they are listed in the table below.

SymbolHow it is drawnWhat it is used for
Flow lineAn arrowShows control passing between the connected shapes
ProcessA rectangleSomething being performed or done, such as a calculation or an assignment
SubroutineA rectangle with double lines down its left and right sidesA call to a subroutine, which is drawn as its own, non-linked flowchart
Input/OutputA parallelogramData being input into, or output from, the flowchart
DecisionA diamondA Yes/No or True/False question, with two lines leaving it for the two possible outcomes
TerminatorA rounded, stadium-shaped boxThe Start and the Stop of the process
Learn the six symbols as shapes rather than words. A decision is always a diamond with exactly two labelled exits, and a process box never has more than one line leaving it.

Standard methods of solution: search, sort, totalling, counting and averages

Cambridge limits the standard methods of solution to six: linear search, bubble sort, totalling, counting, and finding maximum, minimum and average values. You need to recognise each one from its pseudocode, complete one that is partly written, and say what it does.

Totalling keeps a running total: the total is set to 0 before the loop and Total ← Total + Value sits inside it. Counting keeps a running count of how many items have been processed: the count is set to 0 before the loop and Count ← Count + 1 sits inside it. The two are often used together so that an average can be worked out as Total / Count.

Finding the maximum starts by setting the maximum to the first value in the list, then compares every remaining value with it and replaces the maximum whenever a larger value turns up. Finding the minimum is the same with the comparison reversed. Setting the maximum to 0 instead of to the first value is a classic error, because a list of negative numbers would leave the maximum sitting at 0.

A linear search checks each item in turn from the start until the item is found or the list runs out. It works on any list, sorted or not, but it is slow on a long list. A bubble sort puts a list into order by comparing neighbouring pairs and swapping them whenever they are in the wrong order, passing through the list again and again until a complete pass produces no swaps. Both of these are built out of the three constructs: a loop for the repetition, a selection for the comparison, and a sequence for the swap.

MethodWhat it doesThe line that does the work
TotallingAdds every value in a list to give a running totalTotal ← Total + Value, with Total set to 0 before the loop
CountingCounts how many items have been processedCount ← Count + 1, with Count set to 0 before the loop
Finding the maximumFinds the largest value in a listIF Value > Maximum THEN Maximum ← Value, with Maximum set to the first value in the list
Finding the minimumFinds the smallest value in a listIF Value < Minimum THEN Minimum ← Value, with Minimum set to the first value in the list
Finding the averageDivides the total by the number of valuesAverage ← Total / Count
Linear searchChecks each item in turn until the item is found or the list endsIF List[Index] = SearchItem THEN Found ← TRUE
Bubble sortCompares neighbouring items and swaps them when they are in the wrong order, repeating until a complete pass makes no swapsIF List[Index] > List[Index + 1] THEN swap the two items using a temporary variable
Describe what a method does rather than naming it. 'It is a bubble sort' earns nothing by itself; 'it compares neighbouring items and swaps them when they are in the wrong order, repeating until a full pass makes no swaps' earns the mark.

Validation, verification and test data

Validation is an automatic check made by the program as data is input, to test whether the data is sensible and allowed. It cannot tell whether the data is correct, only whether it is reasonable. A range check would accept 12/04/2009 as a date of birth for a Year 8 pupil even though it belongs to the wrong pupil, because it is a perfectly valid date.

Verification is a check that the data has been entered accurately, without being changed on the way in. It is about copying, not about sense. The two examinable methods are a visual check, where a person reads the data back and compares it with the source document, and a double entry check, where the data is typed in twice and the program compares the two versions, accepting the data only if they match.

The examinable validation checks are the range check, length check, type check, presence check, format check and check digit. A range check accepts only values between a lowest and a highest; a length check accepts only strings with the right number of characters; a type check accepts only data of the right type; a presence check refuses to accept a field that has been left empty; a format check insists on a particular pattern, such as dd/mm/yyyy for a date; and a check digit is a calculated extra digit added to a long number such as a barcode so that a single mistyped digit can be detected.

Test data has to be chosen deliberately. The four types are normal, abnormal, extreme and boundary data. Extreme data is the largest or smallest acceptable value, while boundary data is the largest or smallest acceptable value together with the corresponding smallest or largest rejected value. For a program that accepts an age from 11 to 18, extreme data would be 11 and 18, and boundary data would be 11 and 18 (which must be accepted) together with 10 and 19 (which must be rejected).

Check or termWhat it testsExample
Range checkThat a value lies between a lowest and a highest acceptable valueAn exam mark must be from 0 to 100
Length checkThat a string contains the right number of charactersA mobile number must be exactly 11 digits
Type checkThat the data is of the right data typeAn age must be an integer, not a word
Presence checkThat a field has not been left emptyA surname field must contain at least one character
Format checkThat the data follows a required patternA date must be entered as dd/mm/yyyy
Check digitThat the digits of a long number have been copied correctlyThe last digit of a barcode is calculated from all the others
Visual checkThat the data on screen matches the source documentReading a name back from the screen and comparing it with the form
Double entry checkThat the same data has been typed in twice in exactly the same wayA password or a bank account number typed in twice and compared
Validation asks whether the data is sensible; verification asks whether the data has been copied accurately. If a question asks which check stops an empty field being accepted, the answer is a presence check, and if it asks which one detects a mistyped digit in a long number, the answer is a check digit.

Dry runs, trace tables and finding errors

A dry run is working through an algorithm by hand, line by line, writing down the value of every variable as it changes. A trace table is how you record a dry run: one column for each variable, one row for each pass through the algorithm, and often a column showing what the algorithm outputs.

Work down the algorithm in order and write the value of a variable only after it has been changed. Leave a cell empty until that variable has a value, and never guess the final answer and work backwards: the marks are for the intermediate values as the algorithm runs. If a loop runs four times, the trace table needs four rows, and the output goes in its own row after the loop has finished.

The trace table below follows an algorithm that adds up only those scores of 50 or more, and counts how many of them there are. The four scores input are 40, 60, 70 and 30, and the algorithm outputs the value of Count once the loop has finished.

Dry runs are also the best way to find errors. The errors you will be asked about usually fall into a few types: a loop whose condition never becomes false, so the algorithm never finishes; a variable that is used before it has been given a value; a comparison written the wrong way round, so the algorithm takes the wrong branch; a loop that runs one time too many or one time too few; and an OUTPUT statement left inside a loop when it should sit after the loop, so the answer is printed several times.

When you are asked to suggest a correction, write the statement as it should be. 'Change the loop' earns nothing, but 'change UNTIL Count > 10 to UNTIL Count = 10' earns the mark, because the examiner can see exactly what you mean and where.

IndexScore inputScore >= 50?TotalCount
140FALSE00
260TRUE601
370TRUE1302
430FALSE1302
Output2
One row per pass through the loop, and a final row for the output. A trace table with only the last value filled in scores nothing, however right that value is.

Key terms you must be able to define

Algorithm
A sequence of steps that solves a problem. The steps are in a fixed order, each step is unambiguous, and the sequence finishes after a finite number of steps.
Program development life cycle
The four stages a program goes through: analysis, design, coding and testing.
Decomposition
Breaking a problem down into its component parts, or sub-problems, until each part is small enough to solve on its own.
Abstraction
Removing the detail that does not matter for the problem being solved and keeping only the detail that does.
Sub-system
A part of a larger system. Every computer system is made up of sub-systems, and each sub-system is made up of further sub-systems.
Structure diagram
A diagram that shows a problem at the top with its sub-problems broken down underneath, level by level.
Flowchart
A diagram of a solution in which shapes representing processes, decisions and input/output are joined by arrows showing the flow of control.
Pseudocode
A way of writing an algorithm as precise statements using the syllabus keywords, such as DECLARE, INPUT, OUTPUT, IF and REPEAT, which can later be turned into program code.
Sequence
Statements carried out one after another, in the order in which they are written.
Selection
A construct in which the program chooses between different paths, using an IF statement or a CASE statement.
Iteration
A construct in which statements are repeated. It may be a count-controlled loop, a pre-condition loop or a post-condition loop.
Dry run
Working through an algorithm by hand, step by step, writing down the value of each variable as it changes.
Trace table
A table used to document a dry run, with one column for each variable and one row for each pass through the algorithm.
Validation
An automatic check made by the program as data is input, to test whether the data is sensible and allowed. It does not check whether the data is correct.
Verification
A check that data has been entered accurately and has not been changed on the way in. The two methods are the visual check and the double entry check.
Range check
A validation check that accepts only values lying between a lowest and a highest acceptable value.
Length check
A validation check that accepts only strings containing a set number of characters.
Type check
A validation check that accepts only data of the expected data type, such as an integer where a number is required.
Presence check
A validation check that refuses to accept a field that has been left empty.
Format check
A validation check that accepts only data following a required pattern, such as a date written as dd/mm/yyyy.
Check digit
An extra digit calculated from the other digits of a long number and added to it, so that a single digit typed wrongly can be detected.
Visual check
A verification method in which a person reads the data back and compares it with the source document.
Double entry check
A verification method in which the data is typed in twice and the program compares the two versions, accepting it only if they match.
Normal data
Test data of the kind a reasonable user would be expected to enter, which the program should accept.
Abnormal data
Test data that the program should reject, such as a value outside the accepted range or a word where a number is expected.
Extreme data
Test data consisting of the largest or smallest acceptable value.
Boundary data
Test data consisting of the largest or smallest acceptable value together with the corresponding smallest or largest rejected value.
Linear search
A search that checks each item in turn from the start until the item is found or the list ends.
Bubble sort
A sort that compares neighbouring items and swaps them when they are in the wrong order, repeating passes through the list until a complete pass makes no swaps.

Applied to real systems

Cambridge sets 0478 in systems you already use - a phone, a school network, a supermarket till, a website, a bank. Use these as models for how to apply the theory to a context you have not seen before, then write your own.

In a supermarket

Every barcode ends in a check digit calculated from all the other digits. If a digit is misread or mistyped, the check digit will not match, so the till rejects the code instead of charging the wrong price. The barcode number is also checked for length and format, which is why a short code or one containing a letter never gets as far as looking up the product.

At a cash machine

A cash machine uses several validation checks on the same keypad entry. A presence check makes sure something has been typed, a length check makes sure the PIN has the right number of digits, a type check makes sure every character is a digit, and a range check makes sure the amount requested is not larger than the daily limit. The amount is also verified by asking the customer to confirm it before the cash is handed over.

In a school office

A school's attendance system decomposes into sub-systems for registration, absence checking and letters home, and each of those is broken down again. The registration sub-system has its own inputs (the mark for each pupil), processes (totalling the present pupils and comparing the total with the number on roll), output (the daily summary) and storage (the running total while the register is taken).

On an online order form

When you place an order, the postcode is checked against a format, the card number against a check digit, and the house number with a presence check so that the order cannot be sent nowhere. If any check fails, the order is not submitted, which is why a form sometimes refuses to accept what you have typed and highlights one box in red.

In a theme park queue

A height restriction is a decision, so it is drawn in a flowchart as a diamond. The rider's height is input, the decision box asks whether the height is greater than or equal to the minimum, and one exit leads to a process box that admits the rider while the other leads to an output telling them they are too short. Boundary data for testing that program is exactly the minimum height, which must be admitted, and one centimetre less, which must be turned away.

In a music app

Sorting a playlist by title is a bubble sort. The app compares each pair of neighbouring titles, swaps them when they are in the wrong order, and repeats the passes until a complete pass makes no swaps at all. Only then is the list in order, which is why a very long playlist can take a moment to sort on an older phone.

Flashcards

Click a card to flip it. Mark honestly — the tracker uses this.

Q1What is an algorithm?
A sequence of steps that solves a problem, in a fixed order, with each step unambiguous and the sequence finishing after a finite number of steps.
Q2Name the four stages of the program development life cycle.
Analysis, design, coding and testing.
Q3What is the difference between decomposition and abstraction?
Decomposition breaks a problem down into its component parts; abstraction removes the detail that is not needed for the problem and keeps only what is.
Q4What is the difference between a pre-condition loop and a post-condition loop?
A pre-condition loop tests the condition before the statements and may run zero times; a post-condition loop tests the condition afterwards and always runs at least once.
Q5Name the six standard flowchart symbols.
Flow line (arrow), process (rectangle), subroutine (double-sided rectangle), input/output (parallelogram), decision (diamond) and terminator (rounded box).
Q6What is a trace table used for?
To document a dry run of an algorithm, with one column for each variable and one row for each pass through the algorithm.
Q7Name the six validation checks.
Range check, length check, type check, presence check, format check and check digit.
Q8Name the two verification methods.
The visual check, where a person compares the data with the source, and the double entry check, where the data is typed in twice and compared.
Q9What is the difference between extreme data and boundary data?
Extreme data is the largest or smallest acceptable value. Boundary data is the largest or smallest acceptable value together with the corresponding smallest or largest rejected value.
Q10How does a linear search work?
It checks each item in turn from the start until the item is found or the list ends, so it works on any list but is slow on a long one.
Q11How does a bubble sort work?
It compares neighbouring items and swaps them when they are in the wrong order, repeating passes through the list until a complete pass makes no swaps.
Q12Why should a maximum be set to the first value in a list rather than to 0?
Because the maximum then starts as a value that really is in the list, so a list of negative numbers, or a largest value that is below 0, still gives the right answer.
0 of 12 marked as known

Exam-style questions

8 questions, 25 marks. Write your answer, then reveal the mark scheme and tick each point you actually made. Answering honestly here is what makes the rest of the site useful.

StateAO11 mark
State what is meant by decomposition when a problem is being solved.

Mark scheme — tick each point you actually made

Examiner tip: One mark, so one clear sentence is enough. Do not describe abstraction here, and do not simply write 'breaking it up' without saying what it is broken into.
IdentifyAO12 marks
A program asks the user to type in a booking reference that must be exactly six digits. Identify a validation check that would reject a reference with only five digits, and a validation check that would reject a reference containing a letter.

Mark scheme — tick each point you actually made

Examiner tip: Name the check and give the reason in the same sentence. A type check would not do here, because a reference of six digits is stored as a string, so a letter is still the right data type.
DescribeAO13 marks
Describe the difference between validation and verification, and give one example of each.

Mark scheme — tick each point you actually made

Examiner tip: Both definitions are needed, and the examples must be one of each. A range check is validation; a double entry check is verification. Swapping them loses the mark.
SuggestAO23 marks
A program accepts a pupil's age, and only ages from 11 to 18 inclusive are accepted. Suggest one piece of normal data, one piece of boundary data and one piece of abnormal data for testing this program, and state what the program should do with each one.

Mark scheme — tick each point you actually made

Examiner tip: Boundary data must include values on both sides of the limit. Saying 'a very large number' describes abnormal data rather than boundary data, and describes it too vaguely to earn the mark.
DemonstrateAO24 marks
Demonstrate how the values of Total and Count change as the following algorithm runs. The three numbers input are 4, 8 and 2. Total ← 0 Count ← 0 FOR Index ← 1 TO 3 INPUT Number Total ← Total + Number IF Number > 5 THEN Count ← Count + 1 ENDIF NEXT Index OUTPUT Total OUTPUT Count Use columns for Index, Number, Total and Count. Show the value of Total and Count after each pass through the loop, and state the two values that are output.

Mark scheme — tick each point you actually made

Examiner tip: One row per pass, and both variables filled in every time, even when a value has not changed. The output goes in a row of its own after the loop, not inside it.
IdentifyAO23 marks
The following algorithm should output the average of twenty numbers, but it does not work correctly. Count ← 0 FOR Index ← 1 TO 20 INPUT Number Total ← Total + Number Count ← Count + 1 NEXT Index Average ← Total / Count OUTPUT Average Identify the error and suggest a correction.

Mark scheme — tick each point you actually made

Examiner tip: Say which variable is at fault, write the correction as a statement, and explain what goes wrong. A correction written as a statement is worth a mark on its own.
ExplainAO24 marks
Explain the purpose of the following algorithm. Maximum ← Score[1] FOR Index ← 2 TO 10 IF Score[Index] > Maximum THEN Maximum ← Score[Index] ENDIF NEXT Index OUTPUT Maximum

Mark scheme — tick each point you actually made

Examiner tip: Stating the purpose is one sentence. The remaining marks are for describing the processes, so work through the algorithm in order rather than repeating the purpose in different words.
StateAO15 marks
State the four stages of the program development life cycle, and state one task carried out at the design stage.

Mark scheme — tick each point you actually made

Examiner tip: Give the four stages in the right order and then name a task that belongs to the design stage. Describing what happens during coding would not answer the last part of the question.

Exam technique for this topic

  • Write algorithms in pseudocode, not in English. Use the conventions in the syllabus: upper-case keywords such as DECLARE, IF, THEN, OUTPUT and REPEAT, the assignment arrow ←, and indentation for every line that sits inside another statement.
  • Learn the six flowchart symbols as shapes. Questions ask you to complete a flowchart or to say which shape is missing, and a process box where a decision box belongs loses the mark even when the logic is right.
  • In a trace table, fill in one row for every pass through the loop and leave the output for a row of its own at the end. Marks are awarded for the intermediate values of the variables, not for the final answer.
  • In a validation question, name the check and say what it tests. 'A range check' on its own earns nothing; 'a range check so that the mark entered is between 0 and 100' earns the mark.
  • For test data questions, give values rather than descriptions. For an accepted range of 11 to 18, boundary data is 11 and 18 (accepted) together with 10 and 19 (rejected), not 'a value slightly too big'.

Why students lose marks here

A student wroteA student wrote: 'Abstraction means breaking a problem down into smaller parts.'
Why it loses marksThis describes decomposition, not abstraction. The two ideas are usually taught together, so they are easy to swap, but a question asking for one will not accept the other.
The answer that scoresDecomposition is breaking a problem down into its component parts, such as splitting an online shop into a basket, a payment system and a delivery calculator. Abstraction is removing the detail that is not needed for the problem being solved and keeping only what is, in the same way that a tube map keeps the stations and the lines but throws away the real distances.
A student wroteA student wrote: 'A WHILE loop repeats the statements until the condition is true, so it always runs at least once.'
Why it loses marksThe student has described a post-condition loop and given it the name of a pre-condition loop. A WHILE loop tests its condition before the statements run, so it can run zero times, and it stops when the condition becomes false, not true.
The answer that scoresA pre-condition loop (WHILE ... DO ... ENDWHILE) tests its condition before the statements are run, so the statements run only while the condition is true and may never run at all. A post-condition loop (REPEAT ... UNTIL) runs the statements first and tests the condition afterwards, so the statements always run at least once and the loop stops when the condition becomes true.
A student wroteA student completed a trace table by writing only the final value of the total in the last row, having worked the answer out in their head.
Why it loses marksThe marks in a trace table question are for the intermediate values of the variables after each pass through the algorithm. A single final value shows no evidence of a dry run, so only one mark at most can be earned from it.
The answer that scoresWrite one row for every pass through the loop and fill in every variable after it has changed. If four values are input, the table needs four rows, each showing the values of the total and the count at that point, followed by a final row showing what the algorithm outputs.
A student wroteA student wrote: 'Validation checks that the data typed into a system is correct.'
Why it loses marksValidation cannot check that data is correct, only that it is sensible and allowed. 12/04/2009 passes every validation check as a date of birth, but it would be wrong for a Year 8 pupil. Checking that the data has been entered accurately is verification, which is a different thing.
The answer that scoresValidation is an automatic check that the data is sensible and allowed, such as a range check that an exam mark lies between 0 and 100, or a presence check that a surname field is not empty. Verification is a check that the data has been entered accurately, using a visual check or a double entry check.
A student wroteA student wrote an algorithm to find the highest score in a list, starting with Maximum ← 0 before comparing each score with it.
Why it loses marksStarting the maximum at 0 only works if every score in the list is positive. If the list contains negative numbers, or if the first value is the largest, the algorithm can output a value that was never in the list at all.
The answer that scoresSet the maximum to the first value in the list, Maximum ← Score[1], and then compare the remaining values with it from the second element onwards. That way the maximum always starts as a value that really is in the list, and the algorithm works whatever the numbers are.