O Level Computer Science 2210 · Area 2 · Algorithms, programming and logic

Program development life cycle and algorithm design

This topic is about working out a solution before anyone types a line of code, and then proving that the solution is right. You need the four stages of the program development life cycle, how a large problem is decomposed into sub-systems, how a solution is shown in a structure diagram, a flowchart or pseudocode, the standard methods of solution, and how validation, verification and test data keep a program honest. Most marks are lost through imprecise wording and half-filled trace tables rather than through not knowing the ideas.

Not started

Syllabus coverage

  • Understand the program development life cycle, limited to analysis, design, coding and testing, and the tasks carried out at each stage
  • Understand that every computer system is made up of sub-systems, which are made up of further sub-systems, and 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, including its inputs, processes, outputs and storage
  • 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, length, type, presence, format 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 O Level Computer Science syllabus 2210.

Design the solution before writing the codeAnalysis and design come before coding; testing uses normal, abnormal, extreme and boundary data.A trace table dry-runs an algorithm, which is how an error is found before it is run.The program development life cycleanalysiswhat is the problem and what is requireddesigndecomposition, structure diagrams, flowchartscodingwrite the program and test as you gotestingtest data: normal, abnormal, extreme, boundaryA flowchart readsstartread a valuevalue > 10?yesno
The four stages of the program development life cycle — analysis, design, coding and testing — with a flowchart beside them containing a decision box and a loop that returns to an earlier step.

What an algorithm is, and what explaining its purpose involves

An algorithm is a set of steps that solves a problem. The steps are in a fixed order, each step can mean only one thing, and the set of steps must come to an end. A recipe, the instructions on a ticket machine and the routine a teacher follows to put a class list into alphabetical order are all algorithms, even though none of them is a computer program.

Every algorithm can be broken into four parts: the inputs it is given, the processes it carries out, the outputs it produces and the storage it needs while it is running. A program that prints the average mark of a class takes each mark as input, adds the marks together and divides by how many there are as processes, prints the average as output, and holds Total and Count as storage while the marks are being read.

When a question asks you to explain the purpose of a given algorithm, it wants two different things. Stating the purpose is a single sentence about the job as a whole, such as 'it finds the largest value in the list'. Describing the processes means walking through the algorithm in order and saying what each part does, naming the variables as you go: 'it sets Maximum to the first value, then compares every other value with Maximum and replaces Maximum whenever it meets a larger one'.

Precision is what earns the marks. Cambridge requires decisions to be written as expressions, so x > y is acceptable and x is greater than y is not. The same holds inside a flowchart's decision box: write the condition, not a sentence about it. Use the syllabus keywords in upper case, the assignment arrow ←, and indentation for every line that sits inside another statement.

  • State the purpose in one sentence; spend the remaining marks describing the processes in the order they happen.
  • Name the variables, the outputs and the points where the user is prompted for input.
  • Write every condition as an expression such as Mark >= 50, never as English.
Part of an algorithmWhat it meansExample from a canteen till program
InputsThe data the algorithm is given to work withThe price of each item in the customer's order
ProcessesThe calculations and comparisons the algorithm makesAdding each price to a running total and working out the change due
OutputsThe results the algorithm producesThe total to pay and the change, printed on the receipt
StorageThe values held while the algorithm is runningThe running total and the number of items scanned
An explanation of purpose that only repeats the one-line purpose in different words earns one mark. The rest of the marks are for describing what happens, step by step, in the order the algorithm does it.

The program development life cycle: four stages and the tasks at each one

The program development life cycle describes how a program is produced. For 2210 it is limited to four stages: analysis, design, coding and testing. They are taught in that order because each one depends on the one before, but the cycle can be entered again: if testing shows that the design itself is wrong, the team goes back to the design stage rather than patching the code.

In analysis the team works out what the problem actually is. The tasks are abstraction (stripping out the detail that does not affect the solution), decomposition of the problem into parts, and identification of the problem and its requirements: what must go in, what must come out, what must be stored and what the program must do in between. A requirement written down badly here is expensive, because every later stage is built on it.

In design the team decides how the solution will work, without writing the finished program. Decomposition continues, and the design is recorded as structure diagrams, flowcharts or pseudocode. In coding the design is turned into program code, and each part is tested as soon as it is written; this is iterative testing, and it is the reason a programmer rarely writes two hundred lines before running anything.

In testing the finished program is run with planned test data, and what it produces is compared with what was expected. Testing is a search for errors, not a demonstration that the program works: good test data is chosen to make the program fail, and a test that passes is only useful if it could have failed.

StageTasks carried outWhat the stage produces
AnalysisAbstraction, decomposition, identification of the problem and its requirementsA statement of what the program must do, with its inputs, outputs, storage and the processing needed
DesignFurther decomposition, then structure diagrams, flowcharts and pseudocodeA design that can be handed to a programmer and turned into code
CodingWriting the program code and testing each part as it is written (iterative testing)Working, commented program code
TestingRunning the program with normal, abnormal, extreme and boundary data and comparing actual results with expected resultsA record of the tests, the data used and the results
Use the term iterative testing for the coding stage. A question about the life cycle almost always has a mark for saying that code is tested as it is written, not only at the end.

Sub-systems, decomposition and structure diagrams

Every computer system is made up of sub-systems, and each sub-system is made up of further sub-systems. A school's system has sub-systems for admissions, timetabling and reporting; the reporting sub-system has its own sub-systems for collecting marks, calculating grades and printing reports. Each level does one job and passes its result to the level above, which is what makes a large system possible to build at all.

Decomposition is the act of breaking a problem into its component parts until each part is small enough to solve, test and understand on its own. It pays for itself three times: each part can be designed separately, each part can be tested separately, and different programmers can work on different parts at the same time without waiting for each other.

Decomposition and abstraction are used together in the analysis stage. Decomposition splits the problem up; abstraction then decides what each part needs to know and throws the rest away. A program that calculates a pupil's average mark needs the marks and the number of marks, and has no use for the pupil's address, tutor group or date of birth.

A structure diagram records the decomposition on one page. The whole problem sits at the top, its main sub-problems sit underneath, and each of those is broken down again as far as is useful. Reading downwards shows what the program is made of; reading across shows the parts that can be built in parallel. Each box is a natural candidate for a procedure or a function later on.

  • The top of the diagram is the whole system, never one of its parts.
  • Every box except the top one has exactly one box above it.
  • A box at the bottom of a branch is a part small enough to code on its own.
Do not confuse the two diagrams. A structure diagram shows what the solution is made of; a flowchart shows the order in which things happen, including decisions and loops.

Three ways to design a solution: structure diagrams, flowcharts and pseudocode

A structure diagram is the design tool for showing decomposition. It answers the question 'what is this program made of?' and is at its best when the problem is large and the team needs to divide the work.

A flowchart answers the question 'in what order does this happen?'. Shapes are joined by arrows: a rounded terminator for Start and Stop, a parallelogram for input and output, a rectangle for a process, a rectangle with double lines down its sides for a call to a subroutine, a diamond for a decision with one exit labelled Yes and the other No, and a plain arrow as the flow line. A loop appears as an arrow that carries control back to an earlier shape, which is why a flowchart shows iteration so clearly.

Pseudocode answers the question 'what exactly does each step do?'. It is written with the syllabus keywords (DECLARE, INPUT, OUTPUT, IF, THEN, ELSE, ENDIF, CASE, FOR, NEXT, WHILE, REPEAT, UNTIL) and the assignment arrow ←, and it is indented so that the structure is visible. Because it is closer to program code than the other two, it is the design method you can turn into a working program most directly.

In an exam you may be asked to complete any of the three. Completing a flowchart means adding the missing shape in the right place with the right exit labelled; completing pseudocode means adding the missing statement with the right keywords and indentation. Precision matters in both: Total ← Total + 1 is a statement, 'add one to the total' is not.

Design methodWhat it shows bestWhere it is used
Structure diagramThe parts of the solution and how they sit inside one anotherPlanning the overall shape of a large program and dividing the work
FlowchartThe order of steps, with decisions and loops drawn as shapes and arrowsExplaining a process to someone else, or checking the logic of a decision
PseudocodeThe exact statements and the structure of the codeWorking out the detail of a solution before it is written in a programming language
A decision box always has exactly two exits and both must be labelled. A process box has one exit. If a flowchart needs a third outcome, it needs a second decision box.

Standard methods of solution

2210 limits the standard methods of solution to linear search, bubble sort, totalling, counting and finding maximum, minimum and average values. You are expected to recognise each one from its pseudocode, to complete one that has been left half-written, and to say what a given one does.

Totalling keeps a running total: Total ← 0 before the loop, then Total ← Total + Value inside it. Counting keeps a running count of how many items have been dealt with: Count ← 0 before the loop, then Count ← Count + 1 inside it. Set either of them inside the loop and the running value is wiped out on every pass, which is the single most common error in this topic.

A linear search starts at the first item and checks each one in turn until the item is found or the list runs out. It works whether or not the list is in order, but on a long list it is slow, because on average half the items are checked. Written in pseudocode it is a loop with a condition, a comparison and a flag such as Found ← TRUE.

A bubble sort puts a list into order by comparing neighbouring pairs and swapping them whenever they are the wrong way round. One pass through the list moves the largest remaining value to the end, so the next pass can stop one place earlier. The passes repeat until a complete pass makes no swaps, which is the signal that the list is in order. A swap needs a temporary variable: Temp ← List[Index], then List[Index] ← List[Index + 1], then List[Index + 1] ← Temp.

Finding the maximum sets Maximum to the first value in the list and then compares each remaining value with it, replacing Maximum whenever a larger value appears. Finding the minimum is the same with the comparison reversed. The average is then Total / Count, computed after the loop has finished and not inside it.

MethodWhat it doesThe line that does the work
TotallingAdds every value to give a running totalTotal ← Total + Value, with Total ← 0 set before the loop
CountingCounts how many items have been processedCount ← Count + 1, with Count ← 0 set before the loop
MaximumFinds the largest value in a listIF Value > Maximum THEN Maximum ← Value, with Maximum set to the first value
MinimumFinds the smallest value in a listIF Value < Minimum THEN Minimum ← Value, with Minimum set to the first value
AverageDivides the total by how many values there wereAverage ← Total / Count, after the loop
Linear searchChecks each item in turn until the item is found or the list endsIF List[Index] = SearchItem THEN Found ← TRUE
Bubble sortSwaps neighbouring items that are in the wrong order until a full pass makes no swapsIF List[Index] > List[Index + 1] THEN swap using a temporary variable
Setting a maximum to 0 instead of to the first value only works when every value is positive. A list of negative temperatures would leave the maximum sitting at 0, a number that was never in the list.

Validation: six checks that keep unreasonable data out

Validation is a check made by the program as data is entered, to decide whether the data is sensible and allowed. It cannot decide whether the data is true: a date of birth of 12/04/2009 passes every check as a date, and is still wrong for a pupil in Year 11. Validation keeps obvious rubbish out of the system; it does not guarantee accuracy.

2210 limits the validation checks to six. A range check accepts only values between a lowest and a highest, such as a mark from 0 to 100. A length check accepts only data with the right number of characters, such as a membership number of exactly eight digits. A type check accepts only data of the expected type, so a word is rejected where a number is required.

A presence check refuses to accept a field that has been left empty, which is what stops a form being submitted with no surname. A format check insists on a pattern, such as two digits, a slash, two digits, a slash and four digits for a date, or an @ and a dot in an email address. A check digit is an extra digit calculated from all the others and stuck on the end of a long number such as a barcode or an ISBN, so that a single digit typed wrongly or misread makes the calculated value disagree with the digit stored.

The checks are usually combined. A bank card number is length-checked, format-checked (digits only) and check-digit-checked, and the amount requested at a cash machine is range-checked against the daily limit. Each check catches a different kind of mistake, which is why one check on its own is rarely enough.

CheckWhat it testsExample
Range checkThat a value lies between a lowest and a highest acceptable valueA month number must be from 1 to 12
Length checkThat the data contains the right number of charactersA membership number must be exactly eight characters
Type checkThat the data is of the expected data typeA quantity ordered 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 or read correctlyThe final digit of a barcode is calculated from the others and compared
In a question, name the check and say what it tests. 'A range check' on its own earns nothing; 'a range check so that the month entered is between 1 and 12' earns the mark.

Verification, and choosing test data that is worth running

Verification is a check that the data has been copied accurately and has not been changed on the way in. It is about transcription, not about sense. The two methods in the syllabus are the visual check, where a person reads the data back from the screen and compares it with the source document, and the double entry check, where the same data is typed in twice and the program compares the two versions and accepts the data only if they match exactly.

Double entry is used where a mistake would be expensive and the data is short: a new password, an email address, a bank account number. A visual check is used where a person is checking a printed form or a screen against a paper source, and it depends on the person actually looking, which is its weakness.

Test data is chosen before the program is run, and each item is chosen for a reason. Normal data is the kind of value a sensible user would enter, and the program should accept it. Abnormal data is a value the program should reject, such as a word where a number is expected or a mark of 150. 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, so it tests both sides of the limit.

For a program that accepts a month number from 1 to 12, normal data is 6, extreme data is 1 or 12, boundary data is 1 and 12 (which must be accepted) together with 0 and 13 (which must be rejected), and abnormal data is 45 or the word June. Extreme and boundary data are not the same thing, and a question that asks for boundary data wants the rejected values as well.

Type of test dataWhat it isFor an accepted range of 1 to 12
NormalA typical value the program should accept6
AbnormalA value the program should reject45, or the word June
ExtremeThe largest or smallest acceptable value1 or 12
BoundaryThe largest or smallest acceptable value together with the corresponding smallest or largest rejected value1 and 12 accepted, 0 and 13 rejected
Validation asks whether the data is sensible; verification asks whether it was copied accurately. If a question asks which check catches a mistyped digit in a long number, the answer is a check digit; if it asks how a mistyped password is caught, the answer is a double entry check.

Dry runs, trace tables and correcting errors

A dry run is carrying out an algorithm by hand, line by line, writing down the value of every variable as it changes. A trace table records the dry run: one column for each variable, one row for each pass through the algorithm, and usually a final row for the output.

Work down the algorithm in order and write a value only after the statement that changes it has been carried out. Leave a cell blank until the variable has a value, and never work out the answer first and fill the table backwards: the marks are for the intermediate values, and a table that shows only the final answer scores at most one mark. If a loop runs five times, the table needs five rows, even where a variable does not change on a pass; write the unchanged value in again.

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

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

The trace table below follows an algorithm that reads four temperatures, adds each one to a total and counts how many are above 20. The temperatures entered are 12, 25, 9 and 25.

IndexTemperatureTemperature > 20?TotalCount
112FALSE120
225TRUE371
39FALSE461
425TRUE712
Output712
The final row is for what the algorithm outputs, not for a variable. A trace table that shows only the last values of the variables, however correct they are, scores at most one mark.

Key terms you must be able to define

Algorithm
A set of steps that solves a problem, in a fixed order, with each step unambiguous and the set of steps coming to an end.
Program development life cycle
The four stages a program passes through: analysis, design, coding and testing.
Sub-system
A part of a larger system that does one job, and that may itself be made up of further sub-systems.
Decomposition
Breaking a problem into its component parts until each part is small enough to design, code and test on its own.
Abstraction
Removing the detail that does not affect the solution and keeping only the detail that does.
Structure diagram
A diagram with the whole problem at the top and its sub-problems broken down underneath, level by level.
Flowchart
A diagram of a solution in which shapes for processes, decisions and input or output are joined by arrows showing the order of control.
Pseudocode
An algorithm written as precise statements using the syllabus keywords and the assignment arrow, so that it can be turned into program code.
Iterative testing
Testing each part of a program as soon as it has been written, during the coding stage, rather than waiting until the whole program is finished.
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 until a complete pass makes no swaps.
Validation
An automatic check made as data is entered, to test whether the data is sensible and allowed; it cannot test whether the data is correct.
Verification
A check that data has been copied accurately and not changed on the way in, using a visual check or a double entry check.
Check digit
An extra digit calculated from the other digits of a long number and stored with it, so that a single mistyped digit can be detected.
Normal data
Test data of the kind a sensible user would enter, which the program should accept.
Abnormal data
Test data 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.
Dry run
Carrying out an algorithm by hand, statement by statement, recording the value of each variable as it changes.
Trace table
A table documenting a dry run, with one column per variable and one row for each pass through the algorithm.

In context

2210 sets its questions inside systems a student already uses - a school network, a phone, a supermarket till, a vending machine, a website. These show how the theory is applied to a context you have not seen before, then you answer for the system you are given.

In a school library

When a librarian types an ISBN, the catalogue program works along the list of books one entry at a time until it finds a match or reaches the end, which is a linear search. The last digit of the ISBN is a check digit calculated from the others, so a book whose barcode has been misread is rejected before the wrong title is issued to a pupil.

On sports day

A spreadsheet of finishing times is put into order by a bubble sort: the two fastest neighbouring times are compared, swapped if they are the wrong way round, and the passes repeat until a whole pass makes no swaps. The smallest time then sits at the top, and the average time for the event is the total of the times divided by the number of runners.

At a gym reception

A new member's date of birth must be typed as dd/mm/yyyy, so a format check rejects 3/4/09. The postcode is format-checked, the membership number is length-checked and check-digit-checked, and the email address is typed twice so that a double entry check catches a typing slip before the welcome message is sent to the wrong place.

In a bus timetable program

The program that works out which bus to show accepts a route number from 1 to 40. Normal test data is 12; extreme data is 1 or 40; boundary data is 1 and 40, which must be accepted, together with 0 and 41, which must be rejected; abnormal data is 99 or the word express. Testing with 15 alone would never reveal what happens at the edges of the range.

In a PE department

The department's system decomposes into sub-systems for recording scores, calculating averages and producing reports. The averages sub-system is built and tested on its own with three sets of marks before it is connected to the others, which is iterative testing, and the whole system is tested again with boundary data once every sub-system has been joined together.

Flashcards

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

Q1What is an algorithm?
A set of steps that solves a problem, in a fixed order, with each step unambiguous and the steps coming to an end.
Q2Name the four stages of the program development life cycle.
Analysis, design, coding and testing.
Q3What tasks are carried out in the analysis stage?
Abstraction, decomposition of the problem, and identification of the problem and its requirements.
Q4What is iterative testing?
Testing each part of the program as soon as it is written, during the coding stage, rather than waiting until the whole program is complete.
Q5What is the difference between a structure diagram and a flowchart?
A structure diagram shows what the solution is made of, level by level; a flowchart shows the order of steps, including decisions and loops.
Q6How 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 an unsorted list but is slow on a long one.
Q7Why does a bubble sort repeat its passes?
Because one pass only guarantees that the largest remaining value reaches the end of the unsorted part; the passes repeat until a complete pass makes no swaps.
Q8Where should a total be set to 0?
Once, before the loop. Setting it inside the loop wipes out the running total on every pass.
Q9Name the six validation checks.
Range, length, type, presence, format and check digit.
Q10How does a check digit detect an error?
It is calculated from all the other digits and stored with the number; if one digit is mistyped, the recalculated value no longer matches the stored check digit.
Q11Name the two verification methods.
The visual check, where a person compares the data with the source document, and the double entry check, where the data is typed twice and compared.
Q12What is the difference between extreme 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.
Q13How is a trace table laid out?
One column per variable, one row for each pass through the algorithm, and a final row showing the output.
0 of 13 marked as known

Exam-style questions

8 questions, 28 marks. Write your answer and press Mark my answer — it is marked against the scheme and tells you which points you made and what would gain the next mark. You can still reveal the scheme and mark it yourself instead.

StateAO11 mark
State what is meant by a sub-system.

Mark scheme — tick each point you actually made

Examiner tip: One sentence is enough. Do not describe decomposition here; the mark is for the idea of a part of a system that can be broken down further.
IdentifyAO12 marks
A team is writing a program for a sports club. Identify the stage of the program development life cycle in which each of these tasks is carried out. (a) Deciding which parts the solution will be made of and drawing them as a structure diagram. (b) Running the finished program with normal, abnormal, extreme and boundary data.

Mark scheme — tick each point you actually made

Examiner tip: Give the stage and a reason that matches the task. Writing a program is coding; deciding how it will be built is design; running it with planned data is testing.
DescribeAO13 marks
A leisure centre gives every member an eight-digit membership number ending in a check digit. Describe how the check digit detects an error when a membership number is typed in, and describe one other validation check that would prevent an incomplete membership number being accepted.

Mark scheme — tick each point you actually made

Examiner tip: The check digit is worth two marks: one for how it is produced and one for how it is used to detect the error. The second check must be one that stops an incomplete number, so a range check will not do.
DemonstrateAO24 marks
The following algorithm reads four scores and adds up only those that are 50 or more. Total ← 0 Count ← 0 FOR Index ← 1 TO 4 INPUT Score IF Score >= 50 THEN Total ← Total + Score Count ← Count + 1 ENDIF NEXT Index OUTPUT Total OUTPUT Count The scores entered are 45, 50, 60 and 20. Demonstrate how Total and Count change as the algorithm runs. Use columns for Index, Score, Total and Count, and state the two values that are output.

Mark scheme — tick each point you actually made

Examiner tip: Fill in both variables on every row, including the passes where nothing changes. The two outputs are printed in the order the OUTPUT statements appear.
ExplainAO24 marks
Explain the purpose of the following algorithm. Found ← FALSE Index ← 1 WHILE Index <= 20 AND Found = FALSE DO IF StockCode[Index] = SearchCode THEN Found ← TRUE ELSE Index ← Index + 1 ENDIF ENDWHILE IF Found = TRUE THEN OUTPUT Index ELSE OUTPUT "Not in stock" ENDIF

Mark scheme — tick each point you actually made

Examiner tip: State the purpose first in one sentence, then describe the processes in order. The last mark is for saying what each of the two possible outputs means.
SuggestAO24 marks
A program accepts a month number from 1 to 12 and prints the name of that month. Suggest one piece of normal data, one piece of abnormal data and one piece of boundary 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 needs both sides of each limit. Giving only 1 and 12 answers a question about extreme data, not boundary data.
DemonstrateAO26 marks
A weather station records the rainfall for each of 30 days. Write an algorithm, using pseudocode, that inputs the 30 daily rainfall figures, counts how many days had no rain at all, and outputs the total rainfall and the number of dry days.

Mark scheme — tick each point you actually made

Examiner tip: Initialise both variables before the loop, keep the OUTPUT statements after NEXT Day, and declare every variable you use. The logic is marked, not the exact choice of identifier names.
EvaluateAO34 marks
A small hotel keeps its guest records in a program. The manager wants to improve the accuracy of the data that is entered, and can afford to add only two checks. Evaluate which two validation or verification checks would do most to improve the accuracy of the guest records. Give reasons for your choice.

Mark scheme — tick each point you actually made

Examiner tip: An evaluation must make a choice and justify it, including why the rejected option is weaker. Naming two checks without reasons earns at most one mark.

Exam technique for this topic

  • Write algorithms in pseudocode with the syllabus keywords in upper case, the assignment arrow ←, and indentation for every line inside another statement. English sentences describing the steps earn nothing in a coding question.
  • Learn the flowchart shapes as shapes. A decision is a diamond with exactly two exits, both labelled; a process is a rectangle with one exit; and a loop is drawn as an arrow going back to an earlier shape.
  • In a trace table, write one row for every pass through the loop, even where a value has not changed, and give the output a row of its own at the end. The marks are for the intermediate values.
  • For a validation question, name the check and say what it tests against. For a verification question, choose visual or double entry, and never offer a range check as an answer.
  • For test data, give values rather than descriptions. Boundary data must include the values just outside the range as well as the values at its edges.

Why students lose marks here

A student wroteA student wrote: 'A structure diagram shows the order in which the program runs, including its loops.'
Why it loses marksThat is a description of a flowchart. A structure diagram shows what the solution is made of, level by level, and carries no arrows or order of execution at all.
The answer that scoresA structure diagram shows the whole problem at the top with its sub-problems broken down underneath, and each box is a part of the solution that could become a procedure or a function. A flowchart shows the order in which steps happen, using arrows, a diamond for each decision and a line going back for each loop.
A student wroteA student wrote: 'Validation checks that the data in the database is correct.'
Why it loses marksValidation can only test whether data is sensible and allowed. A date of birth of 12/04/2009 passes a range and a format check for any pupil, and can still belong to the wrong pupil.
The answer that scoresValidation is an automatic check made as data is entered, such as a range check that a month number is from 1 to 12 or a presence check that a surname is not blank. It cannot establish that the data is true; verification, using a visual check or a double entry check, establishes only that the data has been copied accurately.
A student wroteA student set Total ← 0 inside a FOR loop, just before Total ← Total + Value.
Why it loses marksThe total is reset on every pass, so after the loop it holds only the last value added rather than the sum of all of them. The initial value belongs before the loop, not inside it.
The answer that scoresSet Total ← 0 once, before the FOR statement, and keep only Total ← Total + Value inside the loop. The same rule applies to a count: Count ← 0 before the loop and Count ← Count + 1 inside it.
A student wroteA student answered a question about boundary data with: 'a number that is a bit too big'.
Why it loses marksThe answer gives no value and tests only one side of the limit. Boundary data is a specific pair of ideas: the edge of the accepted range and the value immediately outside it.
The answer that scoresFor a range of 1 to 12, boundary data is 1 and 12, which must be accepted, together with 0 and 13, which must be rejected. Extreme data would be just 1 or 12, and abnormal data would be a value such as 45.
A student wroteA student wrote: 'The algorithm is wrong because the loop does not work, so change the loop.'
Why it loses marksThis names no statement and no variable, so the examiner cannot see what should change. Corrections in this topic are marked for being specific.
The answer that scoresQuote the faulty line and write the replacement: 'change UNTIL Count > 10 to UNTIL Count = 10', or 'move OUTPUT Average to after NEXT Index so that it prints once rather than on every pass'.

Where this fits in O Level Computer Science 2210

This page is one topic of Cambridge O Level Computer Science 2210. O Level Computer Science 2210 is the course home: every area and every topic in Cambridge's own order, the papers you sit and what each one tests, and the exam-practice tools. The full topic list, with each topic linked to its revision page, is on the O Level Computer Science 2210 syllabus page.