You are on page 1of 320

8

Section B

2 An algorithm has been written to:

• input the ages of 100 students


• count and output the number of students aged 7 and under 12
• count and output the number of students aged 12 and under 18
• count and output the number of students aged 18 and over.

(a) Complete the pseudocode algorithm:

01 Count7to12 0 ←
02 Count12to18 0 ←
03 CountOver18 0 ←
04 FOR Student ←
1 TO ............................................
05 OUTPUT "Please enter student's age in years "
06 INPUT Age
07 IF Age >= 7 ................................................
08 THEN
09 Count7to12 Count7to12 + 1 ←
10 ENDIF
11 IF Age >= 12 AND Age < 18
12 THEN
13 Count12to18 ←
.........................................
14 ENDIF
15 IF Age >= 18
16 THEN
17 CountOver18 CountOver18 + 1 ←
18 ENDIF
19 NEXT Student
20 OUTPUT "There are ", Count7to12, " students aged 7 and under 12."
21 OUTPUT "There are ", Count12to18, " students aged 12 and under 18."
22 OUTPUT "There are ", ................., " students aged 18 and over."
[4]

(b) Write the extra pseudocode statements that are needed to count and output the number of
students under the age of 7. Use the variable CountUnder7; assume CountUnder7 has
already been set to zero.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/F/M/22


9

3 Four validation checks and five descriptions are shown.

Draw a line from each validation check to the most appropriate description.

Validation check Description

checks that the data input is


between two values

length check

checks that the data input is


an integer

check digit

checks that the data input has


three digits

range check

checks that the data has


been input

type check

checks that the data input has


the correct digits
[4]

© UCLES 2022 0478/22/F/M/22 [Turn over


10

4 This flowchart inputs a whole number. The function INT returns the integer value of a number. For
example, INT (7.5) is 7

An input of -1 ends the routine.

START

INPUT Number

IS Number Yes
END
= –1?
No

C 0
D INT(Number/2)

IS
INT(Number/D) Yes
= Number/D?

No
C C + 1

D D – 1

No IS D =
1?

Yes

Yes IS C =
0?
No

OUTPUT C

© UCLES 2022 0478/22/F/M/22


11

(a) Complete the trace table for the given algorithm using this input data:
7, 6, 5, 4, –1, 12, 34

Number C D OUTPUT

[6]

(b) Describe the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) (i) Describe the problem that occurs if a whole number smaller than 4 and not equal to –1
is input.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Explain how to change the flowchart to prevent this problem occurring.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2022 0478/22/F/M/22 [Turn over
12

5 A database table, FLOWER, is used to keep a record of the type of flowers available to make up a
bouquet.

FlowerID Type Colour Style Fragrance


CN001 Carnation Pink Stem Y
CN002 Carnation Red Stem N
CN103 Carnation White Stem N
CN104 Carnation Yellow Stem Y
CN105 Carnation Pink Spray Y
CN106 Carnation Red Spray N
CN107 Carnation White Spray N
CN108 Carnation Yellow Spray Y
RE101 Rose Pink Stem Y
RE102 Rose Red Stem Y
RE103 Rose White Stem N
RE104 Rose Yellow Stem Y
RE105 Rose Orange Spray Y
RE106 Rose Peach Spray N
LY101 Lily White Spray Y

© UCLES 2022 0478/22/F/M/22


13

A query-by-example has been written to display just the type, style and colour of all flowers that
have no fragrance.

Field: FlowerID Fragrance Style Colour

Table: FLOWER FLOWER FLOWER FLOWER

Sort:

Show: 3 3 3 3

Criteria: =Y

or:

Explain why the query-by-example is incorrect and write a correct query-by-example.

Explanation ......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Field:

Table:

Sort:

Show:

Criteria:

or:
[6]

© UCLES 2022 0478/22/F/M/22


7

Section B

2 Tick (ü) one box in each row to identify the most appropriate data type for each description. Only
one tick (ü) per column.

Data type
Description
Boolean Char Integer Real String
a single character from the keyboard

multiple characters from the keyboard

only one of two possible values

only whole numbers

any number
[4]

3 Give one piece of normal test data and one piece of erroneous test data that could be used to
validate the input of an email address.

State the reason for your choice in each case.

Normal test data ...............................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 2210/21/M/J/22 [Turn over


8

4 The flowchart shows an algorithm that should allow 60 test results to be entered into the variable
Score. Each test result is checked to see if it is 50 or more. If it is, the test result is assigned to the
Pass array. Otherwise, it is assigned to the Fail array.

(a) Complete this flowchart:

START

PassCount 0

FailCount 0

Count 0

Yes No

Count Count + 1

No

Yes

END

[6]
© UCLES 2022 2210/21/M/J/22
9

(b) Write a pseudocode routine that will check that each test result entered into the algorithm is
between 0 and 100 inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 2210/21/M/J/22 [Turn over


10

5 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division.
For example, R = 9 MOD 4 gives the value R = 1

First ← 0
Last ←
0
INPUT Limit
FOR Counter ← 1 TO Limit
INPUT Value
IF Value >= 100
THEN
IF Value < 1000
THEN
First ← Value DIV 100
Last ←Value MOD 10
IF First = Last
THEN
OUTPUT Value
ENDIF
ENDIF
ENDIF
NEXT Counter

(a) Complete the trace table for the algorithm using this input data:

8, 66, 606, 6226, 8448, 642, 747, 77, 121

Counter Value First Last Limit OUTPUT

[5]

© UCLES 2022 2210/21/M/J/22


11

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 2210/21/M/J/22 [Turn over


7

Section B

2 Tick (ü) one box in each row to identify the most appropriate data type for each description. Only
one tick (ü) per column.

Data type
Description
Boolean Char Integer Real String
a single character from the keyboard

multiple characters from the keyboard

only one of two possible values

only whole numbers

any number
[4]

3 Give one piece of normal test data and one piece of erroneous test data that could be used to
validate the input of an email address.

State the reason for your choice in each case.

Normal test data ...............................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 0478/21/M/J/22 [Turn over


8

4 The flowchart shows an algorithm that should allow 60 test results to be entered into the variable
Score. Each test result is checked to see if it is 50 or more. If it is, the test result is assigned to the
Pass array. Otherwise, it is assigned to the Fail array.

(a) Complete this flowchart:

START

PassCount 0

FailCount 0

Count 0

Yes No

Count Count + 1

No

Yes

END

[6]
© UCLES 2022 0478/21/M/J/22
9

(b) Write a pseudocode routine that will check that each test result entered into the algorithm is
between 0 and 100 inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/21/M/J/22 [Turn over


10

5 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division.
For example, R = 9 MOD 4 gives the value R = 1

First ← 0
Last ←
0
INPUT Limit
FOR Counter ← 1 TO Limit
INPUT Value
IF Value >= 100
THEN
IF Value < 1000
THEN
First ← Value DIV 100
Last ←Value MOD 10
IF First = Last
THEN
OUTPUT Value
ENDIF
ENDIF
ENDIF
NEXT Counter

(a) Complete the trace table for the algorithm using this input data:

8, 66, 606, 6226, 8448, 642, 747, 77, 121

Counter Value First Last Limit OUTPUT

[5]

© UCLES 2022 0478/21/M/J/22


11

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/21/M/J/22 [Turn over


12

6 A computer game shop records its stock levels in a database table called GAMES. The fields used
in the stock table are shown.

Name Description
GameID primary key
GameName the name of each game
AgeRestriction the minimum age at which a person is allowed to play each game
GamePrice the selling price for each game
NumberStock the quantity of each game currently in stock
OnOrder whether or not each game is on order from the suppliers
DateLastOrdered the date the most recent order for each game was placed
GameDescription a summary of the contents and purpose of each game

(a) State the number of fields that are in the table GAMES.

............................................................................................................................................. [1]

(b) State one important fact that must be true for a field to be a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Complete the query-by-example grid to output all the games that have no stock and that are
on order with the supplier. Display only the GameID, GameName and GamePrice fields in
alphabetical order of the name of the game.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/21/M/J/22


8

Section B

2 An algorithm allows a user to input their password and checks that there are at least eight
characters in the password. Then, the user is asked to re-input the password to check that both
inputs are the same. The user is allowed three attempts at inputting a password of the correct
length and a matching pair of passwords. The pre-defined function LEN(X) returns the number of
characters in the string, X

01 Attempt 0 ←
02 REPEAT
03 PassCheck TRUE ←
04 OUTPUT "Please enter your password "
05 INPUT Password
06 IF LEN(Password) < 8
07 THEN
08 PassCheck TRUE ←
09 ELSE
10 OUTPUT "Please re-enter your password "
11 INPUT Password2
12 IF Password <> Password
13 THEN
14 PassCheck FALSE ←
15 ENDIF
16 ENDIF
17 Attempt ←
Attempt + 1
18 UNTIL PassCheck OR Attempt <> 3
19 IF PassCheck
20 THEN
21 OUTPUT "Password success"
22 ELSE
23 OUTPUT "Password fail"
24 ENDIF

(a) Identify the three errors in the pseudocode and suggest a correction to remove each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................
[3]

© UCLES 2022 2210/22/M/J/22


9

(b) The algorithm includes two types of check on the data input.
Identify and describe each type of check.

Type of check 1 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................

Type of check 2 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................
[4]

(c) Give two sets of test data for this algorithm and a reason for choosing each set.

Each set of test data and its reason must be different.

Set 1 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

3 (a) Describe a one-dimensional array. Include an example of an array declaration.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain how indexing could be used to search for a value stored in a one-dimensional array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 2210/22/M/J/22 [Turn over


10

4 This algorithm checks the temperature of hot food being served to customers.
Error

START

Counter 0
Hot 0
Cold 0
Serve 0

INPUT Temp

Is Temp Yes Error


= –1? ((Hot + Cold) / Counter) * 100

No

Is Temp Yes OUTPUT


Hot Hot + 1
> 86? "Too Hot"

Counter No
Counter + 1 OUTPUT
Error
Is Temp Yes
Cold Cold + 1
< 63?
No
OUTPUT
Serve Serve + 1 "Too Cold"
END

© UCLES 2022 2210/22/M/J/22


11

(a) Complete the trace table for the algorithm using this input data:

75, 78, 84, 87, 91, 80, 75, 70, 65, 62, –1, 20

Counter Hot Cold Serve Temp Error OUTPUT

[7]

(b) State how the final output from the algorithm could be improved.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Identify the process in the algorithm that is not required.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2022 2210/22/M/J/22 [Turn over


12

5 A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.

This is part of the table:

ItemNumber Description SingleUse Uses StockLevel ReorderLevel

DIG1 Glove (pair) Y 1 500 800

DIA1 Apron Y 1 700 800

DIM5 Hair net Y 1 650 500

DIA2 Apron N 5 25 100

DIS4 Suit N 3 70 50

DIV9 Shoe cover (pair) Y 1 400 250

(a) Complete this query-by-example grid to display only the item number and the description of
single use items, where the stock level is below the reorder level.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

(b) Give a reason why the field SingleUse is not required in the table NURSE.

...................................................................................................................................................

............................................................................................................................................. [1]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 2210/22/M/J/22


8

Section B

2 An algorithm allows a user to input their password and checks that there are at least eight
characters in the password. Then, the user is asked to re-input the password to check that both
inputs are the same. The user is allowed three attempts at inputting a password of the correct
length and a matching pair of passwords. The pre-defined function LEN(X) returns the number of
characters in the string, X

01 Attempt 0 ←
02 REPEAT
03 PassCheck TRUE ←
04 OUTPUT "Please enter your password "
05 INPUT Password
06 IF LEN(Password) < 8
07 THEN
08 PassCheck TRUE ←
09 ELSE
10 OUTPUT "Please re-enter your password "
11 INPUT Password2
12 IF Password <> Password
13 THEN
14 PassCheck FALSE ←
15 ENDIF
16 ENDIF
17 Attempt ←
Attempt + 1
18 UNTIL PassCheck OR Attempt <> 3
19 IF PassCheck
20 THEN
21 OUTPUT "Password success"
22 ELSE
23 OUTPUT "Password fail"
24 ENDIF

(a) Identify the three errors in the pseudocode and suggest a correction to remove each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................
[3]

© UCLES 2022 0478/22/M/J/22


9

(b) The algorithm includes two types of check on the data input.
Identify and describe each type of check.

Type of check 1 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................

Type of check 2 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................
[4]

(c) Give two sets of test data for this algorithm and a reason for choosing each set.

Each set of test data and its reason must be different.

Set 1 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

3 (a) Describe a one-dimensional array. Include an example of an array declaration.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain how indexing could be used to search for a value stored in a one-dimensional array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/22/M/J/22 [Turn over


10

4 This algorithm checks the temperature of hot food being served to customers.
Error

START

Counter 0
Hot 0
Cold 0
Serve 0

INPUT Temp

Is Temp Yes Error


= –1? ((Hot + Cold) / Counter) * 100

No

Is Temp Yes OUTPUT


Hot Hot + 1
> 86? "Too Hot"

Counter No
Counter + 1 OUTPUT
Error
Is Temp Yes
Cold Cold + 1
< 63?
No
OUTPUT
Serve Serve + 1 "Too Cold"
END

© UCLES 2022 0478/22/M/J/22


11

(a) Complete the trace table for the algorithm using this input data:

75, 78, 84, 87, 91, 80, 75, 70, 65, 62, –1, 20

Counter Hot Cold Serve Temp Error OUTPUT

[7]

(b) State how the final output from the algorithm could be improved.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Identify the process in the algorithm that is not required.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2022 0478/22/M/J/22 [Turn over


12

5 A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.

This is part of the table:

ItemNumber Description SingleUse Uses StockLevel ReorderLevel

DIG1 Glove (pair) Y 1 500 800

DIA1 Apron Y 1 700 800

DIM5 Hair net Y 1 650 500

DIA2 Apron N 5 25 100

DIS4 Suit N 3 70 50

DIV9 Shoe cover (pair) Y 1 400 250

(a) Complete this query-by-example grid to display only the item number and the description of
single use items, where the stock level is below the reorder level.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

(b) Give a reason why the field SingleUse is not required in the table NURSE.

...................................................................................................................................................

............................................................................................................................................. [1]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/22/M/J/22


7

Section B

2 Tick (3) one or more boxes in each row to match the type(s) of test data to each description.

Types of test data


Description Erroneous /
Boundary Extreme Normal
Abnormal

test data that is always on the limit of


acceptability

test data that is either on the limit of


acceptability or test data that is just
outside the limit of acceptability

test data that will always be rejected

test data that is within the limits of


acceptability

[4]

3 Describe what is meant by the terms variable and constant and give an example of each in your
answer.

Variable ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Constant ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 0478/23/M/J/22 [Turn over


8

4 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 11 DIV 4 gives the value Y = 2

Count ←0
INPUT Limit
FOR In ←

1 TO Limit
Logic

TRUE
Test 2
INPUT Number
REPEAT
IF Number / Test = Number DIV Test


THEN
Logic FALSE
ELSE
Test ←Test + 1
ENDIF
UNTIL NOT Logic OR Test >= Number DIV 2
IF Logic


THEN


Store[Count] Number
Count Count + 1
ENDIF
NEXT In
FOR Out ←
0 TO Count - 1
OUTPUT Store[Out]
NEXT Out

(a) Complete the trace table for the algorithm using this input data:
5, 9, 5, 8, 10, 7

Store
In Logic Test Number Count Limit Out OUTPUT
[Count]

[7]
© UCLES 2022 0478/23/M/J/22
9

(b) State the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) This algorithm only works for numbers that are 3 or greater.

Describe how you could change this algorithm to make sure that only numbers that are
3 or greater are entered. Any pseudocode statements used in your answer must be fully
described.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/M/J/22 [Turn over


10

5 The flowchart shows an algorithm that should:


• allow 100 numbers to be entered into the variable Number
• total the numbers as they are entered
• output the total and average of the numbers after they have all been entered.

Complete this flowchart:

START

Total 0

Counter 0

No

Yes

END
[6]
© UCLES 2022 0478/23/M/J/22
11

6 Data about planets in the solar system is stored in a database table called PLANETS. The fields
used in the table are shown.

Name of field Contents of field


PlanetName the name of the planet
PlanetMass the planet’s mass in kilograms
Larger whether or not the planet has a greater mass than Earth
MaxDistance the maximum distance the planet is from Earth in kilometres
MinDistance the minimum distance the planet is from Earth in kilometres
YearLength the length of time it takes for the planet to orbit the Sun in Earth days

(a) State the name of the field that could contain Boolean data.

............................................................................................................................................. [1]

(b) Complete the query-by-example grid to output the planets with a longer year length and
greater mass than Earth. Assume Earth’s year length is 365 days.

Display only the name of the planets sorted in alphabetical order.

Field:

Table:

Sort:

Show: o o o o o
Criteria:

or:
[3]

© UCLES 2022 0478/23/M/J/22


8

Section B

2 An algorithm has been written to:

• set 100 elements of the array Reading[1:100] to zero


• input integer values between 1 and 100
• end the process with an input of –1
• reject all other values
• count and output the number of times each value is input, starting with the largest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

O2 Reading[Count] 0

03 NEXT Count

04 OUTPUT "Please enter next reading "

05 INPUT Value

06 WHILE Value <> -1 DO

07 IF Value <= 0 OR .................................................................................................

08 THEN

09 OUTPUT "Reading out of range"

10 ELSE

11 Reading[Value] .......................................................................................

12 ENDIF

13 OUTPUT "Please enter next reading "

14 ......................................................................................................................................

15 ENDWHILE

16 Count 100

17 REPEAT

18 OUTPUT "There are ", .............................................................................,


" readings of ", Count

19 Count ...................................................................................................................

20 UNTIL Count = 0
[6]

© UCLES 2022 0478/21/O/N/22


9

(b) Describe how the algorithm could be changed so that it does not output any counts of zero.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22 [Turn over


10

3 (a) A PIN (personal identification number) is input into a banking app by the user. Before the PIN
is accepted, the following validation checks are performed:

• check 1 – each character must be a digit


• check 2 – there must be exactly four digits
• check 3 – the value of the PIN must be between 1000 and 9999 inclusive.

Describe each validation check.

Check 1 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 3 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

(b) The PIN can be changed by the user.

Describe how the new PIN could be verified before use.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22


12

4 This algorithm makes sure that there are enough fresh bread rolls available for customers to buy.

START

Stock 50
Total 0

INPUT Sold

Yes
IS Sold = OUTPUT Total
–1?

No
STOP
Stock Stock – Sold

Yes OUTPUT
IS Stock
< 20? "Add new stock"

No

Total Total + Sold Stock Stock + 50

© UCLES 2022 0478/21/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:
24, 12, 6, 30, 12, 18, –1, 24

Sold Stock Total OUTPUT

[4]

(b) Identify the problem that will occur if the input data starts with a value of 70.
Explain how you would correct this problem.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22 [Turn over


14

5 A database table, WAREHOUSE, is used to keep a record of items for sale. The table has these
fields:

• ItemCode – code to identify each type of item


• Description – brief description of each item
• Manufacturer – name of manufacturer
• Level – number in stock
• Price – price in dollars ($).

(a) State which field you would choose for the primary key. Give a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the item code and the manufacturer
where the number in stock is below 10.

Field:

Table:

Sort:

Show: o o o o
Criteria:

or:
[3]

© UCLES 2022 0478/21/O/N/22


7

Section B

2 Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description

carrying out an action multiple times within a loop


structure

counting

adding together the numbers in a list of numbers


repetition

tracking the number of iterations a program has


selection performed in a loop

sequence
branching off to take a course of action depending
on the answer to a question

totalling

a set of statements to be executed in order

[4]

3 Describe the use of verification on input of data when entering a list of items in stock into a
database. Explain why verification is necessary.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

4 Describe one type of test data that must be used to test if a program accepts valid input data.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

© UCLES 2022 2210/22/O/N/22 [Turn over


8

5 This pseudocode should allow 500 marks to be entered into the algorithm. If the mark is 80 or
greater it is stored in an array for higher marks. If the mark is less than 80, but greater than or
equal to 50 it is stored in an array for middle marks. The remaining marks are stored in an array
for lower marks. The results from the algorithm are displayed at the end.

01 HighList 0
02 MidList 0
03 LowList 0
04 MarksEntry 0
05 REPEAT
06 INPUT Mark
07 IF Mark >= 80
08 THEN
09 Higher[HighList] MarksEntry
10 HighList HighList + 1
11 ELSE
12 IF Mark >= 50
13 THEN
14 Middle[MidList] Mark
15 MidList MidList
16 ELSE
17 Lower[HighList] Mark
18 LowList LowList + 1
19 ENDIF
20 ENDIF
21 MarksEntry MarksEntry + 1
22 NEXT MarksEntry = 500
23 OUTPUT "You entered ", HighList, " higher marks"
24 OUTPUT "You entered ", MidList, " middle marks"
25 OUTPUT "You entered ", LowList, " lower marks"

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2022 2210/22/O/N/22
9

(b) The corrected algorithm needs to be changed so that any number of marks may be entered
and the algorithm runs until the user tells it to stop.

Write the new pseudocode statements that would be needed to achieve this and state where
in the algorithm they would be placed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 2210/22/O/N/22 [Turn over


10

6 This flowchart represents an algorithm to divide three-digit numbers into hundreds, tens and units.

The pre-defined function DIV gives the value of the result of integer division, for example
Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division, for example
R = 9 MOD 4 gives the value R = 1

START

Counter 0

Counter Counter + 1

Yes IS
Counter > 7?

No

INPUT
Number

IS Yes
Number < 100?

No

IS Yes
Number > 999?

No

Hundreds Number DIV 100

Temp Number MOD 100

Tens Temp DIV 10

Units Number MOD 10


STOP

OUTPUT "Hundreds: ",


Hundreds, " Tens: ",
Tens, " Units: ", Units

© UCLES 2022 2210/22/O/N/22


11

Complete the trace table for the algorithm using this input data:

97, 876, 4320, 606, 9875, 42, 124

Counter Number Hundreds Temp Tens Units OUTPUT

[5]

© UCLES 2022 2210/22/O/N/22 [Turn over


12

7 A school uses a database table, ASSESS, to keep a record of the internal assessments and the
number of candidates for each of the subjects in its curriculum.

SubjectCode SubjectName Exams Practicals Candidates


COMP Computer Science 2 1 200
INFO Information Technology 1 2 200
MATH Mathematics 3 0 350
PHYS Physics 2 1 120
CHEM Chemistry 2 1 120
BIOL Biology 2 1 200
GEOG Geography 2 0 200
HIST History 2 0 250
GEOL Geology 2 0 80
PHED Physical Education 1 2 350
FREN French 2 2 120
ENGL English 2 2 350

This database only allows the data types:


• text
• number
• currency
• Boolean.

(a) (i) State the most appropriate data type for the fields SubjectCode and Exams.

SubjectCode ......................................................................................................................

Exams ...............................................................................................................................
[1]
(ii) State one reason why the Candidates field could not be of the Boolean data type.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2022 2210/22/O/N/22


13

(b) Show the output given by the query-by-example grid.

Field: SubjectName Practicals Candidates

Table: ASSESS ASSESS ASSESS

Sort: Ascending

Show: 3 3

Criteria: <1

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the subjects with fewer than 150 candidates.
Display only the SubjectCode, SubjectName and Candidates fields in order of the number of
candidates from largest to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 2210/22/O/N/22


7

Section B

2 Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description

carrying out an action multiple times within a loop


structure

counting

adding together the numbers in a list of numbers


repetition

tracking the number of iterations a program has


selection performed in a loop

sequence
branching off to take a course of action depending
on the answer to a question

totalling

a set of statements to be executed in order

[4]

3 Describe the use of verification on input of data when entering a list of items in stock into a
database. Explain why verification is necessary.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

4 Describe one type of test data that must be used to test if a program accepts valid input data.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

© UCLES 2022 0478/22/O/N/22 [Turn over


8

5 This pseudocode should allow 500 marks to be entered into the algorithm. If the mark is 80 or
greater it is stored in an array for higher marks. If the mark is less than 80, but greater than or
equal to 50 it is stored in an array for middle marks. The remaining marks are stored in an array
for lower marks. The results from the algorithm are displayed at the end.

01 HighList 0
02 MidList 0
03 LowList 0
04 MarksEntry 0
05 REPEAT
06 INPUT Mark
07 IF Mark >= 80
08 THEN
09 Higher[HighList] MarksEntry
10 HighList HighList + 1
11 ELSE
12 IF Mark >= 50
13 THEN
14 Middle[MidList] Mark
15 MidList MidList
16 ELSE
17 Lower[HighList] Mark
18 LowList LowList + 1
19 ENDIF
20 ENDIF
21 MarksEntry MarksEntry + 1
22 NEXT MarksEntry = 500
23 OUTPUT "You entered ", HighList, " higher marks"
24 OUTPUT "You entered ", MidList, " middle marks"
25 OUTPUT "You entered ", LowList, " lower marks"

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2022 0478/22/O/N/22
9

(b) The corrected algorithm needs to be changed so that any number of marks may be entered
and the algorithm runs until the user tells it to stop.

Write the new pseudocode statements that would be needed to achieve this and state where
in the algorithm they would be placed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/O/N/22 [Turn over


10

6 This flowchart represents an algorithm to divide three-digit numbers into hundreds, tens and units.

The pre-defined function DIV gives the value of the result of integer division, for example
Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division, for example
R = 9 MOD 4 gives the value R = 1

START

Counter 0

Counter Counter + 1

Yes IS
Counter > 7?

No

INPUT
Number

IS Yes
Number < 100?

No

IS Yes
Number > 999?

No

Hundreds Number DIV 100

Temp Number MOD 100

Tens Temp DIV 10

Units Number MOD 10


STOP

OUTPUT "Hundreds: ",


Hundreds, " Tens: ",
Tens, " Units: ", Units

© UCLES 2022 0478/22/O/N/22


11

Complete the trace table for the algorithm using this input data:

97, 876, 4320, 606, 9875, 42, 124

Counter Number Hundreds Temp Tens Units OUTPUT

[5]

© UCLES 2022 0478/22/O/N/22 [Turn over


12

7 A school uses a database table, ASSESS, to keep a record of the internal assessments and the
number of candidates for each of the subjects in its curriculum.

SubjectCode SubjectName Exams Practicals Candidates


COMP Computer Science 2 1 200
INFO Information Technology 1 2 200
MATH Mathematics 3 0 350
PHYS Physics 2 1 120
CHEM Chemistry 2 1 120
BIOL Biology 2 1 200
GEOG Geography 2 0 200
HIST History 2 0 250
GEOL Geology 2 0 80
PHED Physical Education 1 2 350
FREN French 2 2 120
ENGL English 2 2 350

This database only allows the data types:


• text
• number
• currency
• Boolean.

(a) (i) State the most appropriate data type for the fields SubjectCode and Exams.

SubjectCode ......................................................................................................................

Exams ...............................................................................................................................
[1]
(ii) State one reason why the Candidates field could not be of the Boolean data type.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2022 0478/22/O/N/22


13

(b) Show the output given by the query-by-example grid.

Field: SubjectName Practicals Candidates

Table: ASSESS ASSESS ASSESS

Sort: Ascending

Show: 3 3

Criteria: <1

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the subjects with fewer than 150 candidates.
Display only the SubjectCode, SubjectName and Candidates fields in order of the number of
candidates from largest to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 0478/22/O/N/22


8

Section B

2 An algorithm has been written to:


• set all 50 elements of the array Reading[1:50] to zero
• input values between 35 and 50 inclusive
• end the process when an input of –1 is made or 50 valid numbers have been entered
• reject all other values
• count the number of times each valid value is input
• output the number of times each value has been input, starting with the lowest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

02 Reading[Count] 0

03 NEXT Count

04 Count 1

05 OUTPUT "Please enter next reading "

06 INPUT Value

07 REPEAT

08 IF Value < 35 OR .................................................................................................

09 THEN

10 OUTPUT "Reading out of range"

11 ELSE

12 Reading[Value] .......................................................................................

13 Count = Count + 1

14 ENDIF

15 IF Count <= 50

16 THEN

17 OUTPUT "Please enter next reading "

18 .................................................................................................................................

19 ENDIF

20 UNTIL Value = -1 OR Count > 50

21 Count 35

22 REPEAT

23 OUTPUT "There are ", .....................................................................,


" readings of ", Count

24 Count ...................................................................................................................

25 UNTIL Count > 50 [6]


© UCLES 2022 0478/23/O/N/22
9

(b) Describe how the algorithm could be changed to output the number of times each value has
been input, starting with the highest value.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


10

3 A check digit is to be used to validate an identification number on input. The identification number
contains five digits and the check digit.
The check digit is calculated by adding up the first five digits, dividing by 10 and taking the
remainder.
For example, 5 + 1 + 2 + 4 + 3 divided by 10 gives a remainder of 5 so the six-digit
identification number would be 512435

(a) (i) Calculate the check digit for 69321

...........................................................................................................................................

..................................................................................................................................... [1]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(ii) State which of these identification numbers have incorrect check digits.

A 123455
B 691400
C 722855
D 231200

...........................................................................................................................................

..................................................................................................................................... [2]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(b) (i) Describe an input error that would not be found using this check digit.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Describe a more suitable algorithm to calculate the check digit for this identification
number.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2022 0478/23/O/N/22
11

(c) Identify two other validation checks that could be used when inputting this identification
number.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2022 0478/23/O/N/22 [Turn over


12

4 This algorithm makes sure that there are enough wheelbarrows in stock.

START

Stock 10
Total 0

INPUT Sale

Yes
Is Sale = OUTPUT Total
"N"?

No
STOP
Stock Stock – 1

Yes OUTPUT
Is Stock
< 5? "Add new stock"

No

Total Total + 1 Stock Stock + 10

© UCLES 2022 0478/23/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:

“Y”, “Y”, “Y”, “Y”, “Y”, “Y”, “N”

Stock Total Sale OUTPUT

[4]

(b) Explain how you could extend the algorithm to allow for the sale of more than one wheelbarrow
at a time.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


14

5 A database table, MUSEUM, is used to keep a record of items in the museum. The table has
these fields:
• ItemCode – code for each type of item, for example ART0005
• Description – brief description of each item, for example gold coin
• InStore – whether the item is in store or not, for example Y
• Century – century when item made, for example 18
• Country – country of origin, for example China.

(a) Identify which field you would choose for the primary key.

State a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the description and the country of origin
for those items not in store.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 0478/23/O/N/22


8

Section B

2 An algorithm has been written to:


• set all 50 elements of the array Reading[1:50] to zero
• input values between 35 and 50 inclusive
• end the process when an input of –1 is made or 50 valid numbers have been entered
• reject all other values
• count the number of times each valid value is input
• output the number of times each value has been input, starting with the lowest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

02 Reading[Count] 0

03 NEXT Count

04 Count 1

05 OUTPUT "Please enter next reading "

06 INPUT Value

07 REPEAT

08 IF Value < 35 OR .................................................................................................

09 THEN

10 OUTPUT "Reading out of range"

11 ELSE

12 Reading[Value] .......................................................................................

13 Count = Count + 1

14 ENDIF

15 IF Count <= 50

16 THEN

17 OUTPUT "Please enter next reading "

18 .................................................................................................................................

19 ENDIF

20 UNTIL Value = -1 OR Count > 50

21 Count 35

22 REPEAT

23 OUTPUT "There are ", .....................................................................,


" readings of ", Count

24 Count ...................................................................................................................

25 UNTIL Count > 50 [6]


© UCLES 2022 2210/23/O/N/22
9

(b) Describe how the algorithm could be changed to output the number of times each value has
been input, starting with the highest value.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 2210/23/O/N/22 [Turn over


10

3 A check digit is to be used to validate an identification number on input. The identification number
contains five digits and the check digit.
The check digit is calculated by adding up the first five digits, dividing by 10 and taking the
remainder.
For example, 5 + 1 + 2 + 4 + 3 divided by 10 gives a remainder of 5 so the six-digit
identification number would be 512435

(a) (i) Calculate the check digit for 69321

...........................................................................................................................................

..................................................................................................................................... [1]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(ii) State which of these identification numbers have incorrect check digits.

A 123455
B 691400
C 722855
D 231200

...........................................................................................................................................

..................................................................................................................................... [2]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(b) (i) Describe an input error that would not be found using this check digit.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Describe a more suitable algorithm to calculate the check digit for this identification
number.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2022 2210/23/O/N/22
11

(c) Identify two other validation checks that could be used when inputting this identification
number.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2022 2210/23/O/N/22 [Turn over


12

4 This algorithm makes sure that there are enough wheelbarrows in stock.

START

Stock 10
Total 0

INPUT Sale

Yes
Is Sale = OUTPUT Total
"N"?

No
STOP
Stock Stock – 1

Yes OUTPUT
Is Stock
< 5? "Add new stock"

No

Total Total + 1 Stock Stock + 10

© UCLES 2022 2210/23/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:

“Y”, “Y”, “Y”, “Y”, “Y”, “Y”, “N”

Stock Total Sale OUTPUT

[4]

(b) Explain how you could extend the algorithm to allow for the sale of more than one wheelbarrow
at a time.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 2210/23/O/N/22 [Turn over


14

5 A database table, MUSEUM, is used to keep a record of items in the museum. The table has
these fields:
• ItemCode – code for each type of item, for example ART0005
• Description – brief description of each item, for example gold coin
• InStore – whether the item is in store or not, for example Y
• Century – century when item made, for example 18
• Country – country of origin, for example China.

(a) Identify which field you would choose for the primary key.

State a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the description and the country of origin
for those items not in store.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 2210/23/O/N/22


8

Section B

2 An algorithm has been written in pseudocode to:

• input 25 positive whole numbers less than 100


• find and output the largest number
• find and output the average of all the numbers

01 A ←0
O2 B ←0
03 C ←0
04 REPEAT
05 REPEAT
06 INPUT D
07 UNTIL D > 0 AND D < 100 AND D = INT(D)
08 IF D > B
09 THEN
10 B D ←
11 ENDIF
12 C ← C + D
13 A ← A + 1
14 UNTIL A >= 25
15 E ←C / A
16 OUTPUT "Largest number is ", B
17 OUTPUT "Average is ", E

(a) Give the line number for the statements showing:

Totalling ....................................................................................................................................

Counting ...................................................................................................................................

Range check .............................................................................................................................

Calculating the average ............................................................................................................


[4]

(b) State an example for each type of test data needed to test the input of the number:

Normal test data example .........................................................................................................

Erroneous/abnormal test data example ....................................................................................

Extreme test data example .......................................................................................................


[3]

© UCLES 2021 0478/22/F/M/21


9

(c) The algorithm needs to be changed to include finding and outputting the smallest number input.
Describe how you would change the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

3 Four pseudocode statements and three flowchart symbols are shown.

Draw a line from each pseudocode statement to its correct flowchart symbol.

Pseudocode statement Flowchart symbol

IF X > 12

INPUT X

X Y + Z

OUTPUT X

[4]

© UCLES 2021 0478/22/F/M/21 [Turn over


10

4 This algorithm accepts weights of bags of cookies. Any cookie bag weighing between 0.9 and
1.1 kilograms inclusive is acceptable. Underweight bags weigh less than 0.9 kilograms and
overweight bags weigh more than 1.1 kilograms. An input of a negative number stops the process.
Then the total number of bags, the number of overweight bags and the number of underweight
bags weighed are output.

Accept← 0
Over ← 0
Under← 0
OUTPUT "Enter weight of first cookie bag"
INPUT BagWeight
WHILE BagWeight > 0
IF BagWeight > 1.1
THEN
Error ← 1
ELSE
IF BagWeight < 0.9
THEN
Error ← 2
ELSE
Error ← 0
ENDIF
ENDIF
CASE Error OF
0 : Accept ← Accept + 1
1 : Over ← Over + 1
2 : Under ← Under + 1
ENDCASE
OUTPUT "Weight of next bag?"
INPUT BagWeight
ENDWHILE
Total ← Accept – Over – Under
OUTPUT "Number of bags weighed ", Total
OUTPUT "Number overweight ", Over
OUTPUT "Number underweight ", Under

© UCLES 2021 0478/22/F/M/21


11

(a) Complete a trace table for the given algorithm using this input data:
1.05, 0.99, 1.2, 0.85, 1.1, 0.9, 1.5, 0.95, 1.05, 1.00, 1.07, 0.89, –10

BagWeight Accept Over Under Error Total OUTPUT

[7]

(b) There is an error in this algorithm.


Identify the error and write the corrected pseudocode statement.

Error ..........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2021 0478/22/F/M/21 [Turn over


12

5 A database table, CHOCBAR, is used to keep a record of chocolate bars sold. Chocolate bars are
categorised by:

• SIZE – small or large


• FILLING – brief description, for example mint crunch
• PRICE – price in Rupees, for example ₹2.50
• NUMBERSOLD – how many sold

A database management system uses these data types:

Text Number Currency Boolean

(a) Select the most appropriate data type for these three fields from the four data types shown.
Each data type must be different. State the reason why you chose the data type.

SIZE data type ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

NUMBERSOLD data type ........................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[3]

(b) Complete the query-by-example grid below to display only the price, filling and number sold
of small chocolate bars that have sold fewer than 10 bars.

Field:

Table:

Sort:

Show:

Criteria:

or:

[3]

© UCLES 2021 0478/22/F/M/21


7

Section B

2 Tick (ü) one box in each row to identify if the statement is about validation, verification or both.

Validation Verification Both


Statement
(ü) (ü) (ü)
Entering the data twice to check if both entries are
the same.
Automatically checking that only numeric data has
been entered.
Checking data entered into a computer system
before it is stored or processed.
Visually checking that no errors have been
introduced during data entry.
[3]

3 Name and describe the most appropriate programming data type for each of the examples of data
given. Each data type must be different.

Data: 37

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Data: Cambridge2021

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Data: 47.86

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2021 2210/21/M/J/21 [Turn over


8

4 The pseudocode algorithm shown has been written by a teacher to enter marks for the students in
her class and then to apply some simple processing.

Count 0 ←
REPEAT
INPUT Score[Count]
IF Score[Count] >= 70
THEN
Grade[Count] "A" ←
ELSE
IF Score[Count] >= 60
THEN
Grade[Count] "B" ←
ELSE
IF Score[Count] >= 50
THEN
Grade[Count] "C" ←
ELSE
IF Score[Count] >= 40
THEN
Grade[Count] "D" ←
ELSE
IF Score[Count] >= 30
THEN
Grade[Count] "E" ←
ELSE
Grade[Count] "F" ←
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Count ←
Count + 1
UNTIL Count = 30

(a) Describe what happens in this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 2210/21/M/J/21


9

(b) Write the pseudocode to output the contents of the arrays Score[] and Grade[] along with
suitable messages.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Describe how you could change the algorithm to allow teachers to use it with any size of
class.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 2210/21/M/J/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if –1 is entered.

START

INPUT
Value

IS Yes
Value =
–1 ?
OUTPUT
"Reject: END
No
Abnormal"

IS
No Value >= 50
AND Value
<= 100 ?

Yes

Diff1 100 – Value

Diff2 Value – 50

IS
OUTPUT No Diff1 < 1 OR
"Accept: Normal" Diff2 < 1 ?

Yes

OUTPUT
"Accept:
Extreme"

© UCLES 2021 2210/21/M/J/21


11

(a) Complete the trace table for the input data:

50, 75, 99, 28, 82, 150, –1, 672, 80

Value Diff1 Diff2 OUTPUT

[4]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2021 2210/21/M/J/21 [Turn over


12

6 A library uses a database table, GENRE, to keep a record of the number of books it has in each
genre.

ID GenreName Total Available Loaned Overdue


ABI Autobiography 500 250 250 20
BIO Biography 650 400 250 0
EDU Education 20200 10000 10200 1250
FAN Fantasy 1575 500 1075 13
GFI General Fiction 35253 23520 11733 0
GNF General Non-Fiction 25200 12020 13180 0
HFI Historical Fiction 6300 3500 2800 0
HNF Historical Non-Fiction 8000 1523 6477 0
HUM Humour 13500 9580 3920 46
MYS Mystery 26000 13269 12731 0
PFI Political Fiction 23561 10523 13038 500
PNF Political Non-Fiction 1823 750 1073 23
REF Reference 374 374 0 0
ROM Romance 18269 16800 1469 0
SAT Satirical 23567 12500 11067 0
SCF Science Fiction 36025 25000 11025 0
SPO Sport 45720 32687 13033 3256
THR Thriller 86000 46859 39141 0

(a) State the reason ID could be used as a primary key in the table GENRE.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) State the number of records in the table GENRE.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 2210/21/M/J/21


13

(c) Complete the query-by-example grid to display any genres with overdue books. Only display
the ID, GenreName and Overdue fields in order of the number of books overdue from largest
to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:

[4]

© UCLES 2021 2210/21/M/J/21


8

Section B

2 (a) Write an algorithm in pseudocode to input 500 positive whole numbers. Each number input
must be less than 1000. Find and output the largest number input, the smallest number input
and the range (difference between the largest number and smallest number).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 2210/22/M/J/21


9

(b) Describe how the algorithm could be changed to make testing less time-consuming.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

3 (a) Draw the most appropriate flowchart symbol for each pseudocode statement.

Pseudocode statement Flowchart symbol

IF Number = 20

PRINT Number

Number ← Number + 1

[3]

(b) State the type of each pseudocode statement. For example, X ← X + Y is totalling.
IF Number = 20 ...................................................................................................................

PRINT Number ........................................................................................................................

Number ← Number + 1 ......................................................................................................


[3]

© UCLES 2021 2210/22/M/J/21 [Turn over


10

4 This algorithm checks passwords.

• Each password must be 8 or more characters in length; the predefined function Length
returns the number of characters.
• Each password is entered twice, and the two entries must match.
• Either Accept or Reject is output.
• An input of 999 stops the process.

REPEAT
OUTPUT "Please enter password"
INPUT Password
IF Length(Password) >= 8
THEN
INPUT PasswordRepeat
IF Password <> PasswordRepeat
THEN
OUTPUT "Reject"
ELSE
OUTPUT "Accept"
ENDIF
ELSE
OUTPUT "Reject"
ENDIF
UNTIL Password = 999

(a) Complete the trace table for the algorithm using this input data:
Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999, 888

Password PasswordRepeat OUTPUT

[3]

© UCLES 2021 2210/22/M/J/21


11

(b) Explain how the algorithm could be extended to allow three attempts at inputting the matching
password. Any pseudocode statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................ [4]

5 A one-dimensional array dataArray[1:20] needs each element set to zero.

(a) Write a pseudocode routine that sets each element to zero. Use the most suitable loop
structure.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain why you chose this loop structure.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 2210/22/M/J/21 [Turn over


12

6 A database table, PLANT, is used to keep a record of plants sold by a nursery. The table has these
fields:
• NAME – name of plant
• FLOWER – whether the plant flowers (True) or not (False)
• POSITION – shade, partial shade or sun
• SIZE – small, medium or large
• PRICE – price in $
• NUMBERSOLD – how many sold

A query-by-example grid has been completed to display only the price, name and number sold of
small plants that do not flower.

Field: NAME PRICE NUMBERSOLD SIZE FLOWER POSITION

Table: PLANT

Sort:

Show: 3 3 3

Criteria: = "shade"

or:

Identify the errors in the query-by-example grid.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Rewrite the corrected query-by-example grid.

Field:

Table:

Sort:

Show:

Criteria:

or:

[5]

© UCLES 2021 2210/22/M/J/21


7

Section B

2 Tick (ü) one box in each row to identify if the statement is about validation, verification or both.

Validation Verification Both


Statement
(ü) (ü) (ü)
Entering the data twice to check if both entries are
the same.
Automatically checking that only numeric data has
been entered.
Checking data entered into a computer system
before it is stored or processed.
Visually checking that no errors have been
introduced during data entry.
[3]

3 Name and describe the most appropriate programming data type for each of the examples of data
given. Each data type must be different.

Data: 37

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Data: Cambridge2021

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Data: 47.86

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2021 0478/21/M/J/21 [Turn over


8

4 The pseudocode algorithm shown has been written by a teacher to enter marks for the students in
her class and then to apply some simple processing.

Count 0 ←
REPEAT
INPUT Score[Count]
IF Score[Count] >= 70
THEN
Grade[Count] "A" ←
ELSE
IF Score[Count] >= 60
THEN
Grade[Count] "B" ←
ELSE
IF Score[Count] >= 50
THEN
Grade[Count] "C" ←
ELSE
IF Score[Count] >= 40
THEN
Grade[Count] "D" ←
ELSE
IF Score[Count] >= 30
THEN
Grade[Count] "E" ←
ELSE
Grade[Count] "F" ←
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Count ←
Count + 1
UNTIL Count = 30

(a) Describe what happens in this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/M/J/21


9

(b) Write the pseudocode to output the contents of the arrays Score[] and Grade[] along with
suitable messages.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Describe how you could change the algorithm to allow teachers to use it with any size of
class.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/M/J/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if –1 is entered.

START

INPUT
Value

IS Yes
Value =
–1 ?
OUTPUT
"Reject: END
No
Abnormal"

IS
No Value >= 50
AND Value
<= 100 ?

Yes

Diff1 100 – Value

Diff2 Value – 50

IS
OUTPUT No Diff1 < 1 OR
"Accept: Normal" Diff2 < 1 ?

Yes

OUTPUT
"Accept:
Extreme"

© UCLES 2021 0478/21/M/J/21


11

(a) Complete the trace table for the input data:

50, 75, 99, 28, 82, 150, –1, 672, 80

Value Diff1 Diff2 OUTPUT

[4]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2021 0478/21/M/J/21 [Turn over


12

6 A library uses a database table, GENRE, to keep a record of the number of books it has in each
genre.

ID GenreName Total Available Loaned Overdue


ABI Autobiography 500 250 250 20
BIO Biography 650 400 250 0
EDU Education 20200 10000 10200 1250
FAN Fantasy 1575 500 1075 13
GFI General Fiction 35253 23520 11733 0
GNF General Non-Fiction 25200 12020 13180 0
HFI Historical Fiction 6300 3500 2800 0
HNF Historical Non-Fiction 8000 1523 6477 0
HUM Humour 13500 9580 3920 46
MYS Mystery 26000 13269 12731 0
PFI Political Fiction 23561 10523 13038 500
PNF Political Non-Fiction 1823 750 1073 23
REF Reference 374 374 0 0
ROM Romance 18269 16800 1469 0
SAT Satirical 23567 12500 11067 0
SCF Science Fiction 36025 25000 11025 0
SPO Sport 45720 32687 13033 3256
THR Thriller 86000 46859 39141 0

(a) State the reason ID could be used as a primary key in the table GENRE.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) State the number of records in the table GENRE.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 0478/21/M/J/21


13

(c) Complete the query-by-example grid to display any genres with overdue books. Only display
the ID, GenreName and Overdue fields in order of the number of books overdue from largest
to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:

[4]

© UCLES 2021 0478/21/M/J/21


8

Section B

2 (a) Write an algorithm in pseudocode to input 500 positive whole numbers. Each number input
must be less than 1000. Find and output the largest number input, the smallest number input
and the range (difference between the largest number and smallest number).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 0478/22/M/J/21


9

(b) Describe how the algorithm could be changed to make testing less time-consuming.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

3 (a) Draw the most appropriate flowchart symbol for each pseudocode statement.

Pseudocode statement Flowchart symbol

IF Number = 20

PRINT Number

Number ← Number + 1

[3]

(b) State the type of each pseudocode statement. For example, X ← X + Y is totalling.
IF Number = 20 ...................................................................................................................

PRINT Number ........................................................................................................................

Number ← Number + 1 ......................................................................................................


[3]

© UCLES 2021 0478/22/M/J/21 [Turn over


10

4 This algorithm checks passwords.

• Each password must be 8 or more characters in length; the predefined function Length
returns the number of characters.
• Each password is entered twice, and the two entries must match.
• Either Accept or Reject is output.
• An input of 999 stops the process.

REPEAT
OUTPUT "Please enter password"
INPUT Password
IF Length(Password) >= 8
THEN
INPUT PasswordRepeat
IF Password <> PasswordRepeat
THEN
OUTPUT "Reject"
ELSE
OUTPUT "Accept"
ENDIF
ELSE
OUTPUT "Reject"
ENDIF
UNTIL Password = 999

(a) Complete the trace table for the algorithm using this input data:
Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999, 888

Password PasswordRepeat OUTPUT

[3]

© UCLES 2021 0478/22/M/J/21


11

(b) Explain how the algorithm could be extended to allow three attempts at inputting the matching
password. Any pseudocode statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................ [4]

5 A one-dimensional array dataArray[1:20] needs each element set to zero.

(a) Write a pseudocode routine that sets each element to zero. Use the most suitable loop
structure.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain why you chose this loop structure.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 0478/22/M/J/21 [Turn over


12

6 A database table, PLANT, is used to keep a record of plants sold by a nursery. The table has these
fields:
• NAME – name of plant
• FLOWER – whether the plant flowers (True) or not (False)
• POSITION – shade, partial shade or sun
• SIZE – small, medium or large
• PRICE – price in $
• NUMBERSOLD – how many sold

A query-by-example grid has been completed to display only the price, name and number sold of
small plants that do not flower.

Field: NAME PRICE NUMBERSOLD SIZE FLOWER POSITION

Table: PLANT

Sort:

Show: 3 3 3

Criteria: = "shade"

or:

Identify the errors in the query-by-example grid.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Rewrite the corrected query-by-example grid.

Field:

Table:

Sort:

Show:

Criteria:

or:

[5]

© UCLES 2021 0478/22/M/J/21


7

Section B

2 Draw a line to connect each Data Type to the most appropriate Description.

Data Type Description

Real Must be a whole number

String Must be one of two values

Integer May be any number

Boolean May contain any combination of characters


[3]

3 Identify a suitable validation check that could be used for each piece of normal test data and
describe how it would be used. Each validation check must be different.

Test data for entering an email address: id27@cambridgeuniversity.com

Validation check name .....................................................................................................................

Description of use ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Test data for entering a year: 2021

Validation check name .....................................................................................................................

Description of use ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Test data for entering a name: Ericson-Bower

Validation check name .....................................................................................................................

Description of use ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]
© UCLES 2021 0478/23/M/J/21 [Turn over
8

4 The pseudocode algorithm should allow a user to input the number of scores to be entered and
then enter the scores. The scores are totalled, the total is output and the option to enter another
set of scores is offered.

1 Count 0 ←
2 REPEAT
3 FullScore 20 ←
4 INPUT Number
5 FOR StoreLoop 1 TO Number ←
6 INPUT Score
7 FullScore FullScore ←
8 UNTIL StoreLoop = Number
9 OUTPUT "The full score is ", FullScore
10 OUTPUT "Another set of scores (Y or N)?"
11 OUTPUT Another
12 IF Another = "N"
13 THEN
14 Count 1 ←
15 ENDIF
16 UNTIL Count = 1

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/23/M/J/21


9

(b) Show how you could change the algorithm to store the individual scores in the array
ScoreArray[], then find and print the average score once the scores have all been entered.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/23/M/J/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if 0 is entered at the Op input.

START

INPUT
Op

IS No
Op = 0 ?

Yes
INPUT
Value1

INPUT
Value2

IS Yes
Op = 1 ? Ans Value1 + Value2

END No

IS Yes
Op = 2 ? Ans Value1 - Value2

No

IS Yes
Op = 3 ? Ans Value1 * Value2

No

IS Yes
Op = 4 ? Ans Value1 / Value2

No

OUTPUT
"Input Error"

© UCLES 2021 0478/23/M/J/21


11

(a) Complete the trace table for the algorithm using this input data:

1, 87, 14, 3, 2, 30, 5, 10, 6, 4, 10, 2, 0, 2, 90, 6

Op Value1 Value2 Ans OUTPUT

[5]

(b) State the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Suggest an addition that could be made to the algorithm to make it more useful.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 0478/23/M/J/21 [Turn over


12

6 A car hire company uses a database table, TREAD, to store details of the cars. The table has
fields to represent each car’s licence number, mileage, and the tread depth of each of its four
tyres.

(a) Suggest suitable names for each of the fields described.

Field name

[2]

(b) Complete the query-by-example grid to display cars where all four tyres have a tread depth
of less than 2. Display all the fields, using the field names you created in part (a). The output
should be sorted by licence number.

Field:

Table:

Sort:

Show: o o o o o o
Criteria:

or:
[4]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2021 0478/23/M/J/21


7

Section B

2 Tick (3) one box in each row to identify if the statement is about validation, verification or neither.

Validation Verification Neither


Statement
(3) (3) (3)
a check where data is re-entered to make sure no
errors have been introduced during data entry
an automatic check to make sure the data entered
has the correct number of characters

a check to make sure the data entered is sensible

a check to make sure the data entered is correct

[3]

3 A program checks that the data entered is between 1 and 100 inclusive.

Identify one piece of normal, extreme and erroneous test data for this program, and give a reason
for each.

Normal test data ...............................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Extreme test data .............................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2021 2210/22/O/N/21 [Turn over


8

4 The pseudocode algorithm should work as a calculator and output the result.

1 Continue 1
2 WHILE Continue = 0
3 OUTPUT "Enter 1 for +, 2 for -, 3 for * or 4 for /"
4 INPUT Operator
5 OUTPUT "Enter the first value"
6 INPUT Value1
7 OUTPUT "Enter the second value"
8 OUTPUT Value2
9 IF Operator
10 1: Answer Value1 + Value2
11 2: Answer Value1 - Value2
12 3: Answer Value1 * Value2
13 4: Answer Value1 / Value2
14 ENDCASE
15 OUTPUT "The answer is ", Value1
16 OUTPUT "Do you wish to enter more values (Yes or No)?"
17 INPUT MoreValues
18 IF MoreValues = "No"
19 THEN
20 Continue 1
21 ENDIF
22 UNTIL Continue = 0

(a) Find the five errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 5 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[5]
© UCLES 2021 2210/22/O/N/21
9

(b) The algorithm needs changing to allow only the numbers 1, 2, 3, or 4 to be entered for the
input variable Operator.

Write the pseudocode to perform this task and state where in the algorithm it would be
located.

Pseudocode ..............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Location in algorithm ................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[5]

© UCLES 2021 2210/22/O/N/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if –1 is entered at the List input.

START

List1 ←0
List2 ←0
INPUT
List

Yes IS
List = –1 ?

No

INPUT
Value

IS
List = 1 ?
Yes
List1 ← List1 + Value
No

IS
List = 2 ?
Yes
List2 ← List2 + Value
OUTPUT
"List 1 = ", List1
No

OUTPUT OUTPUT
"List 2 = ", List2 "Input Error"

IS Yes
List1 > List2 ?

No
OUTPUT
"List 1 is greatest"

OUTPUT
"List 2 is greatest"

END

© UCLES 2021 2210/22/O/N/21


11

Complete the trace table for the algorithm using this input data:

2, 77, 2, 16, 1, 35, 2, –7, 5, 18, 1, 11, 1, 12, 2, 20, –1, 18

List Value List1 List2 OUTPUT

[5]

© UCLES 2021 2210/22/O/N/21 [Turn over


12

6 A pet supplier uses the database table, STOCK, to keep records of its products for pets.

The fields are:

Field name Description


ProductID code to identify the product
ProductName name of product
ProductDescription information about the product
Animal type of animal the product is for, e.g. cat, bird, horse
ProductType type of product, e.g. food, toy, medicine
InStock whether the product is in stock or not

(a) (i) Identify the field that could have a Boolean data type.

..................................................................................................................................... [1]

(ii) Identify the field that should be used as the primary key.

..................................................................................................................................... [1]

(b) Complete the query-by-example grid to output the products intended for a cat that are in
stock. Display only the primary key and the name of the products. The output should be
sorted by the primary key.

Field:

Table:

Sort:

Show:

Criteria:

or:

[4]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2021 2210/22/O/N/21


8

Section B

2 An algorithm has been written in pseudocode to generate 50 positive random integers with values
less than or equal to 100. These random integers are stored in the array RandNum[ ]

The function Rand(X, Y) generates a random integer greater than or equal to X and less than Y.
For example, Rand(1, 4) generates 1 or 2 or 3.

1 Count 0
2 REPEAT
3 RandNum[Counter] Rand(1, 100)
4 Count Count + 2
5 UNTIL Count <= 50

(a) Find the four errors in the pseudocode and write a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/21/O/N/21


9

(b) The pseudocode for this algorithm could be shortened by the use of a FOR … NEXT loop.

Rewrite the algorithm using a FOR … NEXT loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Identify another loop structure available in pseudocode.

............................................................................................................................................. [1]

3 A program has been written to check the value of a measurement. The measurement must be a
positive number and given to three decimal places, for example, 3.982

(a) (i) State suitable examples of normal and erroneous test data that could be used to test this
program. For each example give the reason for your choice of test data.

Normal test data example .................................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................

Erroneous test data example ............................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................
[4]

(ii) Explain why two pieces of boundary test data are required for this program.
Give an example of each piece of boundary test data.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2021 0478/21/O/N/21 [Turn over


10

(b) Explain why verification is needed and how verification could be performed by this program.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/O/N/21


11

Question 4 starts on Page 12

© UCLES 2021 0478/21/O/N/21 [Turn over


12

4 The algorithm shown by this flowchart allows the input of examination marks for a class of students.
A mark of –1 ends the process. If a mark is 80 or over then a distinction grade is awarded. The
number of distinctions for the whole class is calculated. If this is over 50% of the class, the class is
awarded a highly commended certificate.

START

←0
←0
Counter
Distinction

INPUT
Mark

IS
Mark = –1?
Yes
Award ← Distinction/Counter
No

Counter ← Counter + 1 IS
Award > 0.5?
Yes OUTPUT
"Highly
Commended"

No

Distinction ← Distinction + 1
END

Yes IS
Mark >= 80?

No

© UCLES 2021 0478/21/O/N/21


13

Complete a trace table for the algorithm using this input data:
88, 74, 60, 90, 84, 87, 95, 72, 84, 66, –1

Counter Distinction Mark Award OUTPUT

[5]

© UCLES 2021 0478/21/O/N/21 [Turn over


14

5 A database table, APPLIANCE, is used to keep a record of kitchen appliances available for sale.

The following data is stored for each appliance:

• CATEGORY – washer, dishwasher, fridge or freezer


• ECONOMYRATING – A, B, C or D
• MANUFACTURER – Baku or ABC
• PRICE – price in $
• CODE – a unique code allocated by the manufacturer e.g. B982
• STOCK – number in stock.

The database management system uses these data types:

Text Number Currency Boolean

The ECONOMYRATING field and MANUFACTURER field have a data type of text.

(a) Identify the most appropriate data type for each field from the four types shown. State the
reason why you chose each data type.

CATEGORY data type ..............................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

CODE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

STOCK data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/21/O/N/21


15

(b) Complete the query-by-example grid to display only the category, manufacturer and code of
the appliances with an economy rating of A.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2021 0478/21/O/N/21


7

Section B

2 Tick (3) one box in each row to identify if the statement is about validation, verification or neither.

Validation Verification Neither


Statement
(3) (3) (3)
a check where data is re-entered to make sure no
errors have been introduced during data entry
an automatic check to make sure the data entered
has the correct number of characters

a check to make sure the data entered is sensible

a check to make sure the data entered is correct

[3]

3 A program checks that the data entered is between 1 and 100 inclusive.

Identify one piece of normal, extreme and erroneous test data for this program, and give a reason
for each.

Normal test data ...............................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Extreme test data .............................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2021 0478/22/O/N/21 [Turn over


8

4 The pseudocode algorithm should work as a calculator and output the result.

1 Continue 1
2 WHILE Continue = 0
3 OUTPUT "Enter 1 for +, 2 for -, 3 for * or 4 for /"
4 INPUT Operator
5 OUTPUT "Enter the first value"
6 INPUT Value1
7 OUTPUT "Enter the second value"
8 OUTPUT Value2
9 IF Operator
10 1: Answer Value1 + Value2
11 2: Answer Value1 - Value2
12 3: Answer Value1 * Value2
13 4: Answer Value1 / Value2
14 ENDCASE
15 OUTPUT "The answer is ", Value1
16 OUTPUT "Do you wish to enter more values (Yes or No)?"
17 INPUT MoreValues
18 IF MoreValues = "No"
19 THEN
20 Continue 1
21 ENDIF
22 UNTIL Continue = 0

(a) Find the five errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 5 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[5]
© UCLES 2021 0478/22/O/N/21
9

(b) The algorithm needs changing to allow only the numbers 1, 2, 3, or 4 to be entered for the
input variable Operator.

Write the pseudocode to perform this task and state where in the algorithm it would be
located.

Pseudocode ..............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Location in algorithm ................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[5]

© UCLES 2021 0478/22/O/N/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if –1 is entered at the List input.

START

List1 ←0
List2 ←0
INPUT
List

Yes IS
List = –1 ?

No

INPUT
Value

IS
List = 1 ?
Yes
List1 ← List1 + Value
No

IS
List = 2 ?
Yes
List2 ← List2 + Value
OUTPUT
"List 1 = ", List1
No

OUTPUT OUTPUT
"List 2 = ", List2 "Input Error"

IS Yes
List1 > List2 ?

No
OUTPUT
"List 1 is greatest"

OUTPUT
"List 2 is greatest"

END

© UCLES 2021 0478/22/O/N/21


11

Complete the trace table for the algorithm using this input data:

2, 77, 2, 16, 1, 35, 2, –7, 5, 18, 1, 11, 1, 12, 2, 20, –1, 18

List Value List1 List2 OUTPUT

[5]

© UCLES 2021 0478/22/O/N/21 [Turn over


12

6 A pet supplier uses the database table, STOCK, to keep records of its products for pets.

The fields are:

Field name Description


ProductID code to identify the product
ProductName name of product
ProductDescription information about the product
Animal type of animal the product is for, e.g. cat, bird, horse
ProductType type of product, e.g. food, toy, medicine
InStock whether the product is in stock or not

(a) (i) Identify the field that could have a Boolean data type.

..................................................................................................................................... [1]

(ii) Identify the field that should be used as the primary key.

..................................................................................................................................... [1]

(b) Complete the query-by-example grid to output the products intended for a cat that are in
stock. Display only the primary key and the name of the products. The output should be
sorted by the primary key.

Field:

Table:

Sort:

Show:

Criteria:

or:

[4]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2021 0478/22/O/N/21


8

Section B

2 An algorithm has been written in pseudocode to generate 50 positive random integers with values
less than or equal to 100. These numbers are stored in the array NumRand[]

The function RandUp(X,Y) generates a random integer greater than X and less than or equal to Y
For example, RandUp(1,4) generates 2 or 3 or 4

1 Count 0
2 WHILE Counter > 50 DO
3 NumRand[Counter] RandUp(1,100)
4 Counter Counter − 2
5 ENDWHILE

(a) Find the four errors in the pseudocode and write a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) The pseudocode for this algorithm could be shortened by the use of a FOR … NEXT loop.

Rewrite the algorithm using a FOR … NEXT loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/23/O/N/21


9

3 A program has been written to check the length and content of a password. The password must be
eight or more characters long and contain at least one special character, for example, Secret!*!

(a) (i) State suitable examples of normal and erroneous test data that could be used to test this
program. For each example give the reason for your choice of test data.

Normal test data example .................................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................

Erroneous test data example ............................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................
[4]

(ii) Explain why two pieces of boundary test data are required for this program.
Give an example of each piece of boundary test data.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(b) Describe two methods of verification that could be used to verify this data as it is input.

Method 1 ...................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Method 2 ...................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/23/O/N/21 [Turn over


10

4 The algorithm, shown by this flowchart, allows the input of examination marks for a class of
students. A mark of 999 ends the process. If a mark is 40 or over then a pass grade is awarded.
The number of pass grades is calculated for the whole class. If this is under 50% of the class, the
class is offered extra help.

START

Counter 0
Pass 0

INPUT
Mark

IS Yes
Mark = 999 ? Help Pass / Counter

No
IS Yes
Counter Counter + 1 OUTPUT
Help < 0.5 ? "Extra Help"

No
Yes IS
Pass Pass + 1 Mark >= 40 ?
END
No

© UCLES 2021 0478/23/O/N/21


11

Complete a trace table for the algorithm using this input data:
88, 24, 60, 30, 44, 17, 25, 22, 54, 6, 999, −1

Counter Pass Mark Help OUTPUT

[5]

© UCLES 2021 0478/23/O/N/21 [Turn over


12

5 A database table, COMPUTER, is used to keep a record of computers available for sale.

The following data is stored for each computer:

• CATEGORY – desktop, laptop or tablet


• WEIGHT – weight in kilograms
• MANUFACTURER – ICN, Linoldo, Pear or JoeSing
• PRICE – price in $
• CODE – a unique code allocated by the manufacturer, e.g. P771
• STOCK – quantity in stock.

A database management system uses these data types:

Text Number Currency Boolean

The CATEGORY field and MANUFACTURER field have a data type of text.

(a) Select the most appropriate data type for each field from the four types shown. State the
reason why you chose the data type.

WEIGHT data type ....................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

CODE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

STOCK data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/23/O/N/21


13

(b) Complete the query-by-example grid to display only the category, manufacturer, price and
code of the computers with weight of less than 2.5 kilograms.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2021 0478/23/O/N/21


8

Section B

2 (a) An algorithm has been written in pseudocode to input 50 numbers. Positive numbers are
stored in the array PosNum[ ]. Negative numbers are stored in the array NegNum[ ].
Zeros are not included in the positive and negative counts.

Count 0 ←
PosCount Count ←
NegCount Count ←
REPEAT
INPUT Number
IF Number > 0
THEN
PosCount PosCount + 1 ←
PosNum[PosCount] Number ←
ELSE
NegCount NegCount + 1 ←
NegNum[NegCount] Number ←
ENDIF
Count ←
Count + 1
UNTIL Count >= 50
OUTPUT "There are ", PosCount," positive numbers"
OUTPUT "There are ", NegCount," negative numbers"

Describe the error in the pseudocode and write the correction for this error.

Error ..........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/22/F/M/20


9

(b) The algorithm needs to be changed so there is no limit to how many numbers can be input.
When the number 9999 is input, the algorithm stops more numbers being input and outputs
the results. The number 9999 is not to be stored nor counted as a positive number.

Explain how you would change the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/22/F/M/20 [Turn over


10

3 This flowchart inputs student percentage marks for three examinations. If the average of these
marks is 80% or over then a distinction grade is awarded. If the average of these marks is less
than 40% then a fail grade is awarded. Otherwise a pass grade is awarded.

START

INPUT
Mark1,Mark2,Mark3

Total Mark1 +
Mark2 + Mark3

Average Total / 3

IS
Yes OUTPUT
Average >= 80 ?
"Distinction"

No

Yes IS
OUTPUT Average < 40 ?
"Fail"

No

OUTPUT
"Pass"

END

© UCLES 2020 0478/22/F/M/20


11

(a) Complete a trace table for each set of input data:

Set 1: 88, 74, 60

Mark1 Mark2 Mark3 Total Average OUTPUT

Set 2: 20, 33, 67

Mark1 Mark2 Mark3 Total Average OUTPUT

Set 3: 79, 91, 70

Mark1 Mark2 Mark3 Total Average OUTPUT

[5]

(b) It has been decided to include an extra grade of Merit when the average of the marks is 60%
or more, and less than 80%. Describe the changes that will need to be made to the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2020 0478/22/F/M/20 [Turn over


12

4 Explain why validation and verification checks are needed when data is input.
Include an example of each type of check in your answer.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2020 0478/22/F/M/20


14

5 A database table, BOX, is used to keep a record of boxes made and sold by a craftsman. Boxes
are categorised by:

• SIZE – small, medium or large


• SHAPE – brief description for example ‘star shaped’
• WOOD – maple, beech, walnut or ebony
• PRICE – price in $
• SOLD – whether the box is sold or not.

A database management system uses these data types:

Text Number Currency Boolean

(a) Select the most appropriate data type for each field from the four types shown. State the
reason why you chose the data type.

SIZE data type ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

SHAPE data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

WOOD data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

SOLD data type ........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[5]

© UCLES 2020 0478/22/F/M/20


15

(b) (i) Complete the query-by-example grid below to only display the price of small walnut
boxes.

Field:

Table:

Sort:

Show:
Criteria:

or:

[3]

(ii) The query-by-example grid from part (b)(i) needs to be changed to show both walnut
and beech boxes and display the wood used. Only one column needs to be changed.
Write the changed column.

Field:

Table:

Sort:

Show:
Criteria:

or:

[2]

© UCLES 2020 0478/22/F/M/20


8

Section B

2 Tick (ü) one box in each row to identify if the statement about structure diagrams is true or false.

True False
Statement
(ü) (ü)
A structure diagram is a piece of code that is available throughout the
structure of a program.
A structure diagram shows the hierarchy of a system.

A structure diagram is another name for an array.

A structure diagram shows the relationship between different components


of a system.
[2]

3 Programs can perform validation and verification checks when data is entered.

(a) Give the names of two different validation checks and state the purpose of each one.

Check 1 .....................................................................................................................................

Purpose .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 .....................................................................................................................................

Purpose .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) Give the name of one verification check.

............................................................................................................................................. [1]

(c) Describe the difference between validation and verification.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 2210/21/M/J/20


9

4 The pseudocode algorithm shown should allow numbers to be entered and should allow
50 numbers to be stored in an array.

Count 0 ←
REPEAT
INPUT Values[Count]
Count ←
Count + 1
UNTIL Count = 0

(a) Explain why the algorithm will never end.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Re-write the original pseudocode so that it terminates correctly and also prevents numbers
below 100 from being stored in the array Values[ ]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(c) Describe how you could change your pseudocode in part (b) so that it prevents numbers
below 100 and above 200 from being stored in the array Values[ ]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 2210/21/M/J/20 [Turn over


10

5 The flowchart represents an algorithm.

The predefined function DIV gives the value of the result of integer division,
for example, y ← 9 DIV 4 gives y a value of 2

An input value of –1 ends the algorithm.

START

INPUT
Value

IS Yes
Value =
-1 ?

No

Calc1 Value DIV 2

Calc2 Value DIV 3

IS
No Calc1 =
Value / 2 ?

Yes

IS
No Calc2 =
Value / 3 ?

Yes

OUTPUT
Value
END

© UCLES 2020 2210/21/M/J/20


11

(a) Complete the trace table for the input data:

50, 33, 18, 15, 30, –1, 45, 12, 90, 6

Value Calc1 Calc2 OUTPUT

[4]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 2210/21/M/J/20 [Turn over


12

6 A garden centre sells garden tools and stores details of these in a database table named TOOLS.
Code is the primary key in the TOOLS table.

Code Description Price ($) Quantity_Stock Quantity_Ordered


GFLG Garden Fork 50.00 1 50
GSLG Garden Spade 50.00 11 0
GHLG Garden Hoe 45.00 8 0
HFSM Hand Fork 9.99 42 0
HSSM Hand Spade 9.99 40 0
HWSM Hand Weeder 9.99 11 0
HS20 Hose (20 metres) 45.00 10 0
HS35 Hose (35 metres) 60.00 2 0
HS50 Hose (50 metres) 75.00 20 60
YBLG Yard Brush 24.99 100 0
LMHD Lawn Mower 99.99 5 0
LMBT Lawn Mower (Battery) 249.99 7 0
LMPT Lawn Mower (Petrol) 349.99 10 25
TRBT Edge Trimmer (Battery) 79.99 15 0
TRPT Edge Trimmer (Petrol) 59.99 20 0
SHSM Shears 40.00 40 0
HCSM Hedge Clippers 40.00 45 0

(a) State the purpose of the primary key in the TOOLS table.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2020 2210/21/M/J/20


13

(b) List the output from the data shown in the table TOOLS that would be given by this query-by-
example.

Field: Code Description Price ($) Quantity_Stock Quantity_Ordered

Table: TOOLS TOOLS TOOLS TOOLS TOOLS

Sort: Descending

Show: ü ü ü
Criteria: >40 >0 >0

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the tools where the quantity in stock is below
25. Only show the Code, Description and Quantity_Stock fields in ascending order of Code.

Field:

Table:

Sort:

Show:

Criteria:

or:

[3]

© UCLES 2020 2210/21/M/J/20


7

Section B

2 Most programming languages include basic data types. Ahmad is describing the basic data types
he has used.

State the data type that Ahmad is describing in each sentence.

Choose the data type from this list of programming terms.

Array Boolean Char Constant Function Integer

Iteration Procedure Real String Variable

A number with a fractional part that can be positive or negative and used in calculations

Data type ..........................................................................................................................................

A whole number that can be positive, negative or zero and used in calculations

Data type ..........................................................................................................................................

A single number, symbol or letter

Data type ..........................................................................................................................................

A sequence of characters

Data type ..........................................................................................................................................

A data type with two values, True or False

Data type ..........................................................................................................................................


[5]

© UCLES 2020 2210/22/M/J/20 [Turn over


8

3 (a) An algorithm has been written in pseudocode to input the names and marks of 35 students.
The algorithm stores the names and marks in two arrays Name[ ] and Mark[ ]. The highest
mark awarded is found and the number of students with that mark is counted. Both of these
values are output.

01 HighestMark 100 ←
02 HighestMarkStudents 0 ←
03 FOR Count ←
1 TO 35
04 OUTPUT "Please enter student name"
05 INPUT Name[Count]
06 OUTPUT "Please enter student mark"
07 INPUT Mark[Counter]
08 IF Mark[Count] = HighestMark
09 THEN
10 HighestMarkStudents HighestMarkStudents – 1 ←
11 ENDIF
12 IF Mark[Count] > HighestMark
13 THEN
14 Mark[Count] HighestMark ←
15 HighestMarkStudents 1 ←
16 ENDIF
17 NEXT Count
18 OUTPUT "There are ", HighestMarkStudents," with the highest mark of ",
HighestMark

Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 2210/22/M/J/20


9

(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the
number of students with that mark, and output both these values.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2020 2210/22/M/J/20 [Turn over
10

4 This flowchart inputs the points won and the points lost when playing a game. The difference
between the points won and lost is calculated and depending on the result the player can: move
up to the next level, stay at the same level, or move down to the previous level. The flowchart
finishes when the input for points won is –1.

START

INPUT
PointsWon, PointsLost

IS
Yes END
PointsWon = –1 ?

No

Difference
PointsWon - PointsLost

OUTPUT IS
Yes
"Well done Difference > =
move up" 1000 ?

No

OUTPUT Yes IS
"Sorry move Difference < 0 ?
down"

No

OUTPUT
"Keep on trying"

© UCLES 2020 2210/22/M/J/20


11

(a) Complete a trace table for this set of input data:


5000, 4474, 6055, 2000, 7900, 9800, 3000, 2150, –1, 6700, 7615

PointsWon PointsLost Difference OUTPUT

[3]

(b) The flowchart needs to be changed. When the difference is more than 5000 the output
message is ‘Fantastic leap up two levels’.

Describe the changes that will need to be made to the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2020 2210/22/M/J/20 [Turn over


12

5 Arrays are data structures used in programming. Explain what is meant by the terms dimension
and index in an array. Use examples of arrays in your explanations.

Dimension ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Index ................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2020 2210/22/M/J/20


13

6 A database table, JUICE, is used to keep a record of cartons of fresh fruit juice available for sale.

Juice code Fruit 1 Fruit 2 Size Volume (ml) Stock level


LMO10 Mango Orange Large 1000 18
MOO05 Orange Orange Medium 500 8
SAM02 Apple Mango Small 200 25
SAA02 Apple Apple Small 200 50
SPP02 Pineapple Pineapple Small 200 10
MMM05 Mango Mango Medium 500 12
LMM10 Mango Mango Large 1000 5
MGG05 Guava Guava Medium 500 5
SMO02 Mango Orange Small 200 7
MOP05 Orange Pineapple Medium 500 12
LAA10 Apple Apple Large 1000 32
SGO02 Guava Orange Small 200 10
LPP10 Pineapple Pineapple Large 1000 3
LOO10 Orange Orange Large 1000 25
SOO02 Orange Orange Small 200 40

(a) Identify a suitable field to use as the primary key. State a reason for your choice.

Field ..........................................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the stock level and size of all cartons
containing only apple juice.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2020 2210/22/M/J/20


8

Section B

2 Tick (ü) one box in each row to identify if the statement about structure diagrams is true or false.

True False
Statement
(ü) (ü)
A structure diagram is a piece of code that is available throughout the
structure of a program.
A structure diagram shows the hierarchy of a system.

A structure diagram is another name for an array.

A structure diagram shows the relationship between different components


of a system.
[2]

3 Programs can perform validation and verification checks when data is entered.

(a) Give the names of two different validation checks and state the purpose of each one.

Check 1 .....................................................................................................................................

Purpose .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 .....................................................................................................................................

Purpose .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) Give the name of one verification check.

............................................................................................................................................. [1]

(c) Describe the difference between validation and verification.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20


9

4 The pseudocode algorithm shown should allow numbers to be entered and should allow
50 numbers to be stored in an array.

Count 0 ←
REPEAT
INPUT Values[Count]
Count ←
Count + 1
UNTIL Count = 0

(a) Explain why the algorithm will never end.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Re-write the original pseudocode so that it terminates correctly and also prevents numbers
below 100 from being stored in the array Values[ ]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(c) Describe how you could change your pseudocode in part (b) so that it prevents numbers
below 100 and above 200 from being stored in the array Values[ ]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20 [Turn over


10

5 The flowchart represents an algorithm.

The predefined function DIV gives the value of the result of integer division,
for example, y ← 9 DIV 4 gives y a value of 2

An input value of –1 ends the algorithm.

START

INPUT
Value

IS Yes
Value =
-1 ?

No

Calc1 Value DIV 2

Calc2 Value DIV 3

IS
No Calc1 =
Value / 2 ?

Yes

IS
No Calc2 =
Value / 3 ?

Yes

OUTPUT
Value
END

© UCLES 2020 0478/21/M/J/20


11

(a) Complete the trace table for the input data:

50, 33, 18, 15, 30, –1, 45, 12, 90, 6

Value Calc1 Calc2 OUTPUT

[4]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20 [Turn over


12

6 A garden centre sells garden tools and stores details of these in a database table named TOOLS.
Code is the primary key in the TOOLS table.

Code Description Price ($) Quantity_Stock Quantity_Ordered


GFLG Garden Fork 50.00 1 50
GSLG Garden Spade 50.00 11 0
GHLG Garden Hoe 45.00 8 0
HFSM Hand Fork 9.99 42 0
HSSM Hand Spade 9.99 40 0
HWSM Hand Weeder 9.99 11 0
HS20 Hose (20 metres) 45.00 10 0
HS35 Hose (35 metres) 60.00 2 0
HS50 Hose (50 metres) 75.00 20 60
YBLG Yard Brush 24.99 100 0
LMHD Lawn Mower 99.99 5 0
LMBT Lawn Mower (Battery) 249.99 7 0
LMPT Lawn Mower (Petrol) 349.99 10 25
TRBT Edge Trimmer (Battery) 79.99 15 0
TRPT Edge Trimmer (Petrol) 59.99 20 0
SHSM Shears 40.00 40 0
HCSM Hedge Clippers 40.00 45 0

(a) State the purpose of the primary key in the TOOLS table.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2020 0478/21/M/J/20


13

(b) List the output from the data shown in the table TOOLS that would be given by this query-by-
example.

Field: Code Description Price ($) Quantity_Stock Quantity_Ordered

Table: TOOLS TOOLS TOOLS TOOLS TOOLS

Sort: Descending

Show: ü ü ü
Criteria: >40 >0 >0

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the tools where the quantity in stock is below
25. Only show the Code, Description and Quantity_Stock fields in ascending order of Code.

Field:

Table:

Sort:

Show:

Criteria:

or:

[3]

© UCLES 2020 0478/21/M/J/20


7

Section B

2 Most programming languages include basic data types. Ahmad is describing the basic data types
he has used.

State the data type that Ahmad is describing in each sentence.

Choose the data type from this list of programming terms.

Array Boolean Char Constant Function Integer

Iteration Procedure Real String Variable

A number with a fractional part that can be positive or negative and used in calculations

Data type ..........................................................................................................................................

A whole number that can be positive, negative or zero and used in calculations

Data type ..........................................................................................................................................

A single number, symbol or letter

Data type ..........................................................................................................................................

A sequence of characters

Data type ..........................................................................................................................................

A data type with two values, True or False

Data type ..........................................................................................................................................


[5]

© UCLES 2020 0478/22/M/J/20 [Turn over


8

3 (a) An algorithm has been written in pseudocode to input the names and marks of 35 students.
The algorithm stores the names and marks in two arrays Name[ ] and Mark[ ]. The highest
mark awarded is found and the number of students with that mark is counted. Both of these
values are output.

01 HighestMark 100 ←
02 HighestMarkStudents 0 ←
03 FOR Count ←
1 TO 35
04 OUTPUT "Please enter student name"
05 INPUT Name[Count]
06 OUTPUT "Please enter student mark"
07 INPUT Mark[Counter]
08 IF Mark[Count] = HighestMark
09 THEN
10 HighestMarkStudents HighestMarkStudents – 1 ←
11 ENDIF
12 IF Mark[Count] > HighestMark
13 THEN
14 Mark[Count] HighestMark ←
15 HighestMarkStudents 1 ←
16 ENDIF
17 NEXT Count
18 OUTPUT "There are ", HighestMarkStudents," with the highest mark of ",
HighestMark

Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/22/M/J/20


9

(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the
number of students with that mark, and output both these values.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2020 0478/22/M/J/20 [Turn over
10

4 This flowchart inputs the points won and the points lost when playing a game. The difference
between the points won and lost is calculated and depending on the result the player can: move
up to the next level, stay at the same level, or move down to the previous level. The flowchart
finishes when the input for points won is –1.

START

INPUT
PointsWon, PointsLost

IS
Yes END
PointsWon = –1 ?

No

Difference
PointsWon - PointsLost

OUTPUT IS
Yes
"Well done Difference > =
move up" 1000 ?

No

OUTPUT Yes IS
"Sorry move Difference < 0 ?
down"

No

OUTPUT
"Keep on trying"

© UCLES 2020 0478/22/M/J/20


11

(a) Complete a trace table for this set of input data:


5000, 4474, 6055, 2000, 7900, 9800, 3000, 2150, –1, 6700, 7615

PointsWon PointsLost Difference OUTPUT

[3]

(b) The flowchart needs to be changed. When the difference is more than 5000 the output
message is ‘Fantastic leap up two levels’.

Describe the changes that will need to be made to the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2020 0478/22/M/J/20 [Turn over


12

5 Arrays are data structures used in programming. Explain what is meant by the terms dimension
and index in an array. Use examples of arrays in your explanations.

Dimension ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Index ................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2020 0478/22/M/J/20


13

6 A database table, JUICE, is used to keep a record of cartons of fresh fruit juice available for sale.

Juice code Fruit 1 Fruit 2 Size Volume (ml) Stock level


LMO10 Mango Orange Large 1000 18
MOO05 Orange Orange Medium 500 8
SAM02 Apple Mango Small 200 25
SAA02 Apple Apple Small 200 50
SPP02 Pineapple Pineapple Small 200 10
MMM05 Mango Mango Medium 500 12
LMM10 Mango Mango Large 1000 5
MGG05 Guava Guava Medium 500 5
SMO02 Mango Orange Small 200 7
MOP05 Orange Pineapple Medium 500 12
LAA10 Apple Apple Large 1000 32
SGO02 Guava Orange Small 200 10
LPP10 Pineapple Pineapple Large 1000 3
LOO10 Orange Orange Large 1000 25
SOO02 Orange Orange Small 200 40

(a) Identify a suitable field to use as the primary key. State a reason for your choice.

Field ..........................................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the stock level and size of all cartons
containing only apple juice.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2020 0478/22/M/J/20


8

Section B

2 Draw a line to connect each Description to the most appropriate Pseudocode example.

Description Pseudocode example

A loop that will iterate


CASE … OF … OTHERWISE … ENDCASE
at least once

A loop that will not be


executed on the first test Number Number + 1
if the condition is false

A conditional statement WHILE … DO … ENDWHILE

Totalling Sum Sum + NewValue

Counting REPEAT … UNTIL

[4]

© UCLES 2020 0478/23/M/J/20


9

3 This section of pseudocode is to be used as a validation check that will continue until a number
between 0 and 499 inclusive is entered.

1 PRINT "Input a number from 0 to 499 inclusive"


2 FOR Number 1 TO 10
3 INPUT Number
4 IF Number < 0 AND Number > 499
5 THEN
6 PRINT "Invalid number, please try again"
7 ENDIF
8 UNTIL Number = 0 OR Number = 499
9 PRINT Number, " is within the correct range"

There are three lines in this pseudocode that contain errors. In each case, state the line number
to identify the incorrect line and write out the corrected line in full.

Error 1 line number ..........................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 2 line number ..........................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 3 line number ..........................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2020 0478/23/M/J/20 [Turn over


10

4 A code must take the form LL9 9LL where L is a letter and 9 is a digit.

(a) A presence check has already been used to ensure data has been entered. Name two other
types of validation check that can be used to test the code is valid.

Check 1 .....................................................................................................................................

Check 2 .....................................................................................................................................
[2]

(b) Give one example of invalid test data for each of the validation checks you have named in
part (a) and in each case, give a reason why it fails the check. Each example of test data
must be different.

Check 1 Invalid Test Data .........................................................................................................

...................................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 Invalid Test Data .........................................................................................................

...................................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/23/M/J/20


11

5 This algorithm finds prime numbers.

The pre-defined function DIV gives the value of the result of integer division,
for example, y 9 DIV 4 gives y a value of 2

Flag False
INPUT Number
WHILE Number <> 0
Divisor 2
WHILE Divisor <= Number / 2
Value Number DIV Divisor
IF Number / Divisor = Value
THEN
Flag True
ENDIF
Divisor Divisor + 1
ENDWHILE
IF Flag = False
THEN
OUTPUT Number, " is prime"
ENDIF
INPUT Number
Flag False
ENDWHILE

Complete the trace table for the algorithm using the input data:

5, 6, 8, 0, 11, 13

Flag Number Divisor Value OUTPUT

[5]

© UCLES 2020 0478/23/M/J/20 [Turn over


12

6 Draw the flowchart symbol for Decision and the flowchart symbol for Process.

Decision Process

[2]

7 A convenience store which sells general groceries wants to set up a database table called
STOCK. The table will contain fields including a description of the item, the price of the item
and the number in stock for each item. The STOCK table also has a fourth field to be used as a
primary key.

(a) Complete the table to suggest a suitable field name for each of the four fields in the table
STOCK. Give the purpose of the data to be stored in each field.

Field name Purpose of field contents

[4]

(b) Complete the query-by-example grid to output stock items where the quantity in stock has
fallen below 20. Only show the primary key and description of the items.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2020 0478/23/M/J/20


8

Section B

2 Tick (3) one box in each row to identify if the statement about subroutines is true or false.

true false
Statement
(3) (3)
A subroutine is called from within a program.

A subroutine is not a complete program.

A subroutine is a self-contained piece of code.

A subroutine must return a value to the code from which it was called.
[2]

3 This pseudocode algorithm is used as a validation check.

PRINT "Input a number from 1 to 5000"


REPEAT
INPUT Number
IF Number < 1 OR Number > 5000
THEN
PRINT "Invalid number, please try again"
ENDIF
UNTIL Number >= 1 AND Number <= 5000
PRINT Number, " is within the correct range"

Identify three different types of test data. For each type, give an example of the test data you
would use to test this algorithm and state a reason for your choice of test.

Type of test data 1 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Type of test data 2 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Type of test data 3 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2020 2210/22/O/N/20


9

4 This pseudocode algorithm allows 5000 numbers to be entered and stored in an array called
Number.

FOR Count 1 TO 5000


INPUT Number[Count]
NEXT Count

Extend and re-write the algorithm using pseudocode to also count and output how many of the
numbers stored in the array are greater than 500, using the variable Higher. Only output Higher
once with an appropriate message.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [6]
© UCLES 2020 2210/22/O/N/20 [Turn over
10

5 This pseudocode represents an algorithm.

REPEAT
Flag 0
FOR Count 0 to 3
IF Num[Count] < Num[Count + 1]
THEN
Store Num[Count]
Num[Count] Num[Count + 1]
Num[Count + 1] Store
Flag 1
ENDIF
NEXT Count
UNTIL Flag = 0

(a) The contents of the array at the start of the algorithm are:

Num[0] Num[1] Num[2] Num[3] Num[4]


45 56 30 12 15

Complete the trace table for the algorithm using the data given in the array.

Flag Count Num[0] Num[1] Num[2] Num[3] Num[4] Store


45 56 30 12 15

[5]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
© UCLES 2020 2210/22/O/N/20
11

6 Draw a flowchart symbol to represent each of the following:

Input/Output Decision

[2]

Question 7 starts on Page 12.

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2020 2210/22/O/N/20 [Turn over


12

7 The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the
items sold by a music shop.

PartNum Description Cost Quantity


A01 Compact Amplifier Case 50.00 15
A02 Deluxe Amplifier Case 75.00 1
A03 Amplifier Standard 79.99 48
A04 Amplifier Midrange 149.99 50
A05 Amplifier Megablaster 299.99 48
S01 Tweeter 59.99 10
S02 Midrange Woofer 99.99 0
S03 Subwoofer 139.99 16
S04 Tower Speaker Basic 159.99 25
S05 Tower Speaker Skyscraper 219.99 9
S06 Centre Speaker 149.99 25
S07 Soundbar 89.99 2
S20 Soundbar 129.99 0
S21 Ceiling Surround Speaker 75.00 15
S22 Ceiling Full Range Speaker 100.00 1
S25 Surround Speaker 100.00 60
T19 Speaker Stands (Pair) 75.00 60

(a) State the number of records in the table AUDIOPARTS

............................................................................................................................................. [1]

(b) Identify the field that is most suitable to be a primary key and give a reason for your choice.

Fieldname .................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

(c) Complete the query-by-example grid to show the items where the quantity in stock is fewer
than 10. Show all the fields from the database table in descending order of cost.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]
© UCLES 2020 2210/22/O/N/20
7

Section B

2 Describe the purpose of variables and constants. Use an example of each in your answer.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2020 0478/21/O/N/20 [Turn over


8

3 This pseudocode algorithm calculates the weight and number of bags in a load of firewood. The
weight in kilograms of each bag is input. The algorithm finishes when either 50 bags have been
weighed, or as soon as the total weight exceeds 1000 kilograms. Only then are the total weight
and the number of bags in the load output.

01 TotalWeight ←
1000
02 BagCount 0 ←
03 MaxBag 50 ←
04 MaxWeight ←
1000
05 REPEAT
06 OUTPUT "Please Enter weight of bag"
07 INPUT Weight
08 TotalWeight ←
TotalWeight + Weight
09 BagCount ←
BagCount + 1
10 OUTPUT "Number of bags in the load is ", BagCount
11 UNTIL TotalWeight > MaxWeight AND BagCount >= MaxBag
12 OUTPUT "Total weight of the load is ", MaxWeight

(a) Give the line number(s) from the algorithm of:

an assignment statement .........................................................................................................

a loop ........................................................................................................................................

a counting statement ................................................................................................................

a totalling statement .................................................................................................................


[4]

(b) Give the line numbers of the four errors in this pseudocode. Suggest a correction for each
error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2020 0478/21/O/N/20
9

(c) Explain how you could extend the algorithm to calculate and display the average weight of a
bag of firewood in the load.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/21/O/N/20 [Turn over


10

4 This flowchart inputs five numbers and performs a calculation.

The predefined function MOD finds the remainder from integer division for example
R ← 25 MOD 11 gives R a value of 3

START

INPUT
V,W,X,Y,Z

IS Yes
V = 0? END

No

A ← V*2 + W*3 + X*4 + Y*5

B ← A MOD 11

Yes IS
OUTPUT
"Valid" B = Z?

No

OUTPUT
"Invalid"

© UCLES 2020 0478/21/O/N/20


11

(a) Complete the trace table for this set of input data:
5, 4, 6, 2, 1, 9, 3, 2, 1, 6, 7, 6, 1, 5, 1, 0, 0, 0, 0, 0

V W X Y Z A B OUTPUT

[4]

(b) Describe the purpose of this flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/O/N/20 [Turn over


12

5 A database table, AIRLINE, stores data used to compare airlines.

Number of Number of Head office Share price


Code Airline name
employees countries
FJ FastJet 60000 30 Europe 514.50
MA MurphyAir 35000 8 Europe 152.67
JS JetSeven 45000 22 Asia 257.44
K3 Koala3 22000 11 Australia 501.21
NS NorthState 30000 4 America 108.22
SS SouthState 30000 4 America 126.35
BJ BlueJet 15000 7 Africa 215.45
SK SkyKing 32000 27 Europe 506.12
PF PandaFly 50000 35 Asia 317.88

(a) State how many fields and how many records are shown in the AIRLINE table.

Number of Fields ......................................................................................................................

Number of Records ..................................................................................................................


[2]

(b) Show the output that would be given by this query-by-example.

Field: Airline name Number of employees Head office Share price


Table: AIRLINE AIRLINE AIRLINE AIRLINE
Sort:

Show: 3 3
Criteria: < 35000 > 500.00
or:

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/O/N/20


13

(c) Complete the query-by-example grid to find every airline with a head office in Asia or Africa,
and number of countries greater than 4. Only show the airline name and number of countries.

Field:

Table:
Sort:

Show:
Criteria:
or:

[4]

© UCLES 2020 0478/21/O/N/20


8

Section B

2 Tick (3) one box in each row to identify if the statement about subroutines is true or false.

true false
Statement
(3) (3)
A subroutine is called from within a program.

A subroutine is not a complete program.

A subroutine is a self-contained piece of code.

A subroutine must return a value to the code from which it was called.
[2]

3 This pseudocode algorithm is used as a validation check.

PRINT "Input a number from 1 to 5000"


REPEAT
INPUT Number
IF Number < 1 OR Number > 5000
THEN
PRINT "Invalid number, please try again"
ENDIF
UNTIL Number >= 1 AND Number <= 5000
PRINT Number, " is within the correct range"

Identify three different types of test data. For each type, give an example of the test data you
would use to test this algorithm and state a reason for your choice of test.

Type of test data 1 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Type of test data 2 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Type of test data 3 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2020 0478/22/O/N/20


9

4 This pseudocode algorithm allows 5000 numbers to be entered and stored in an array called
Number.

FOR Count 1 TO 5000


INPUT Number[Count]
NEXT Count

Extend and re-write the algorithm using pseudocode to also count and output how many of the
numbers stored in the array are greater than 500, using the variable Higher. Only output Higher
once with an appropriate message.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [6]
© UCLES 2020 0478/22/O/N/20 [Turn over
10

5 This pseudocode represents an algorithm.

REPEAT
Flag 0
FOR Count 0 to 3
IF Num[Count] < Num[Count + 1]
THEN
Store Num[Count]
Num[Count] Num[Count + 1]
Num[Count + 1] Store
Flag 1
ENDIF
NEXT Count
UNTIL Flag = 0

(a) The contents of the array at the start of the algorithm are:

Num[0] Num[1] Num[2] Num[3] Num[4]


45 56 30 12 15

Complete the trace table for the algorithm using the data given in the array.

Flag Count Num[0] Num[1] Num[2] Num[3] Num[4] Store


45 56 30 12 15

[5]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
© UCLES 2020 0478/22/O/N/20
11

6 Draw a flowchart symbol to represent each of the following:

Input/Output Decision

[2]

Question 7 starts on Page 12.

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2020 0478/22/O/N/20 [Turn over


12

7 The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the
items sold by a music shop.

PartNum Description Cost Quantity


A01 Compact Amplifier Case 50.00 15
A02 Deluxe Amplifier Case 75.00 1
A03 Amplifier Standard 79.99 48
A04 Amplifier Midrange 149.99 50
A05 Amplifier Megablaster 299.99 48
S01 Tweeter 59.99 10
S02 Midrange Woofer 99.99 0
S03 Subwoofer 139.99 16
S04 Tower Speaker Basic 159.99 25
S05 Tower Speaker Skyscraper 219.99 9
S06 Centre Speaker 149.99 25
S07 Soundbar 89.99 2
S20 Soundbar 129.99 0
S21 Ceiling Surround Speaker 75.00 15
S22 Ceiling Full Range Speaker 100.00 1
S25 Surround Speaker 100.00 60
T19 Speaker Stands (Pair) 75.00 60

(a) State the number of records in the table AUDIOPARTS

............................................................................................................................................. [1]

(b) Identify the field that is most suitable to be a primary key and give a reason for your choice.

Fieldname .................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

(c) Complete the query-by-example grid to show the items where the quantity in stock is fewer
than 10. Show all the fields from the database table in descending order of cost.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]
© UCLES 2020 0478/22/O/N/20
8

Section B

2 An algorithm has been written in pseudocode to check the temperature readings taken from a
freezer are within the range –18 degrees to –25 degrees inclusive.

The algorithm counts the number of times that the temperature reading is below –25 degrees and
the number of times that the temperature reading is above –18 degrees.

An engineer is called if there are more than 10 temperature readings below –25 degrees.

An alarm sounds if there are more than 5 temperature readings above –18 degrees.

01 TooHot 0
02 TooCold 1000
03 REPEAT
04 OUTPUT "Please enter temperature"
05 INPUT Temperature
06 IF Temperature < -25
07 THEN
08 TooCold TooCold – 1
09 ENDIF
10 IF Temperature > -18
11 THEN
12 TooHot TooHot + 1
13 ENDIF
14 UNTIL TooHot > 5 OR TooCold > 10
15 IF TooHot < 5
16 THEN
17 INPUT "Alarm!!"
18 ENDIF
19 IF TooCold > 10
20 THEN
21 OUTPUT "Call the Engineer"
22 ENDIF

(a) Give the line number(s) from the algorithm of:

an assignment statement .........................................................................................................

a loop ........................................................................................................................................

a counting statement ................................................................................................................

a selection statement ................................................................................................................


[4]

© UCLES 2020 0478/23/O/N/20


9

(b) Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(c) Explain how you could extend the algorithm to count the number of times the temperature
readings are within the range –18 degrees to –25 degrees inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/23/O/N/20 [Turn over


10

3 Four programming concepts and five descriptions are shown.

Draw a line to connect each Programming concept to its correct Description. Not all Descriptions
will be connected to a Programming concept.

Programming concept Description

A subroutine that does not have to


Validation
return a value

An automatic check to ensure that data


input is reasonable and sensible
Verification

A subroutine that always returns


a value

Procedure
An overview of a program or subroutine

A check to ensure that data input


Function
matches the original
[4]

© UCLES 2020 0478/23/O/N/20


12

4 This flowchart represents an algorithm that allows the input of two numbers and performs a
calculation.

The predefined function MOD finds the remainder from integer division for example X 8 MOD 5
gives X a value of 3.

START

INPUT
Y,Z

IS Yes
Y = 0? END

No

IS Yes
Y > Z? A Y MOD Z

No

A Z MOD Y

OUTPUT Yes IS
"Valid" A = 0?

No

OUTPUT
"Invalid"

© UCLES 2020 0478/23/O/N/20


13

(a) Complete a trace table for this set of input data:


11, 4, 6, 2, 3, 9, 3, 2, 2, 6, 0, 0, 1, 1

Y Z A OUTPUT

[4]

(b) Explain the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/23/O/N/20 [Turn over


14

5 A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.

Creature Class Quantity Ready for release Offspring


Manta Ray Fish 3 Y N
Short-tailed Albatross Bird 4 Y N
Emperor Penguin Bird 50 Y Y
Bluefin Tuna Fish 2 N N
Manatee Mammal 4 Y N
Hawksbill Turtle Reptile 10 Y Y
Hammerhead Shark Fish 3 Y N
Yellow-eyed Penguin Bird 4 Y N
Kemp’s Ridley Sea Turtle Reptile 1 Y N

(a) State how many fields and how many records are shown in this table.

Number of fields .......................................................................................................................

Number of records ....................................................................................................................


[2]

(b) Show the output that would be given by this query-by-example.

Field: Creature Class Ready for release

Table: MARINE MARINE MARINE

Sort:

Show: 3 3
Criteria: ="Bird"

or:

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/23/O/N/20


15

(c) Complete the query-by-example grid to display the creatures, in ascending order of quantity,
that have no offspring and are ready for release. Display only the creature field.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]

© UCLES 2020 0478/23/O/N/20


8

Section B

2 An algorithm has been written in pseudocode to check the temperature readings taken from a
freezer are within the range –18 degrees to –25 degrees inclusive.

The algorithm counts the number of times that the temperature reading is below –25 degrees and
the number of times that the temperature reading is above –18 degrees.

An engineer is called if there are more than 10 temperature readings below –25 degrees.

An alarm sounds if there are more than 5 temperature readings above –18 degrees.

01 TooHot 0
02 TooCold 1000
03 REPEAT
04 OUTPUT "Please enter temperature"
05 INPUT Temperature
06 IF Temperature < -25
07 THEN
08 TooCold TooCold – 1
09 ENDIF
10 IF Temperature > -18
11 THEN
12 TooHot TooHot + 1
13 ENDIF
14 UNTIL TooHot > 5 OR TooCold > 10
15 IF TooHot < 5
16 THEN
17 INPUT "Alarm!!"
18 ENDIF
19 IF TooCold > 10
20 THEN
21 OUTPUT "Call the Engineer"
22 ENDIF

(a) Give the line number(s) from the algorithm of:

an assignment statement .........................................................................................................

a loop ........................................................................................................................................

a counting statement ................................................................................................................

a selection statement ................................................................................................................


[4]

© UCLES 2020 2210/23/O/N/20


9

(b) Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(c) Explain how you could extend the algorithm to count the number of times the temperature
readings are within the range –18 degrees to –25 degrees inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 2210/23/O/N/20 [Turn over


10

3 Four programming concepts and five descriptions are shown.

Draw a line to connect each Programming concept to its correct Description. Not all Descriptions
will be connected to a Programming concept.

Programming concept Description

A subroutine that does not have to


Validation
return a value

An automatic check to ensure that data


input is reasonable and sensible
Verification

A subroutine that always returns


a value

Procedure
An overview of a program or subroutine

A check to ensure that data input


Function
matches the original
[4]

© UCLES 2020 2210/23/O/N/20


12

4 This flowchart represents an algorithm that allows the input of two numbers and performs a
calculation.

The predefined function MOD finds the remainder from integer division for example X 8 MOD 5
gives X a value of 3.

START

INPUT
Y,Z

IS Yes
Y = 0? END

No

IS Yes
Y > Z? A Y MOD Z

No

A Z MOD Y

OUTPUT Yes IS
"Valid" A = 0?

No

OUTPUT
"Invalid"

© UCLES 2020 2210/23/O/N/20


13

(a) Complete a trace table for this set of input data:


11, 4, 6, 2, 3, 9, 3, 2, 2, 6, 0, 0, 1, 1

Y Z A OUTPUT

[4]

(b) Explain the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 2210/23/O/N/20 [Turn over


14

5 A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.

Creature Class Quantity Ready for release Offspring


Manta Ray Fish 3 Y N
Short-tailed Albatross Bird 4 Y N
Emperor Penguin Bird 50 Y Y
Bluefin Tuna Fish 2 N N
Manatee Mammal 4 Y N
Hawksbill Turtle Reptile 10 Y Y
Hammerhead Shark Fish 3 Y N
Yellow-eyed Penguin Bird 4 Y N
Kemp’s Ridley Sea Turtle Reptile 1 Y N

(a) State how many fields and how many records are shown in this table.

Number of fields .......................................................................................................................

Number of records ....................................................................................................................


[2]

(b) Show the output that would be given by this query-by-example.

Field: Creature Class Ready for release

Table: MARINE MARINE MARINE

Sort:

Show: 3 3
Criteria: ="Bird"

or:

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 2210/23/O/N/20


15

(c) Complete the query-by-example grid to display the creatures, in ascending order of quantity,
that have no offspring and are ready for release. Display only the creature field.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]

© UCLES 2020 2210/23/O/N/20


8

Section B

2 (a) An algorithm has been written in pseudocode to input 50 numbers and total only the positive
numbers.

Count 1 ←
Total ←
Count
REPEAT
INPUT Number
IF Number <> 0
THEN
Total ←
Total + Count
ENDIF
Count ←
Count + 1
UNTIL Count < 50
PRINT Total

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(b) Show how you would change the corrected algorithm to only total numbers greater than 0
and less than 20.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/22/F/M/19


10

3 This flowchart inputs the type of passenger for a survey: S for Senior, A for Adult, C for Child. All
other values are ignored, apart from Z which ends the process.

START

Senior 0
Adult 0
Child 0

INPUT Type

Is Type = Yes
Senior Senior + 1
"S" ?

No

Is Type = Yes
Adult Adult + 1
"A" ?

No

Is Type = Yes
Child Child + 1
"C" ?

No

No Is Type =
"Z" ?

Yes
OUTPUT "Seniors ", Senior
OUTPUT "Adults ", Adult
OUTPUT "Children ", Child

END

© UCLES 2019 0478/22/F/M/19


11

Complete the trace table for the passenger input data:


S, S, S, A, C, C, C, A, A, A, A, W, S, S, D, C, Z, D, S

Senior Adult Child Type OUTPUT

[5]

© UCLES 2019 0478/22/F/M/19 [Turn over


12

4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition

FOR X ← 1 TO 10
SUM ← SUM + 1
NEXT X
WHILE X > 10 DO
SUM ← SUM + 1
X ←X - 1
ENDWHILE
IF X > 10
THEN
SUM ← SUM + 1
X ←X - 1
ENDIF
REPEAT
SUM ← SUM + 1
X ←X - 1
UNTIL X > 10
[4]

© UCLES 2019 0478/22/F/M/19


13

5 A programmer restricts input values to less than 90 and greater than 60.

(a) State whether this is called validation or verification.

...................................................................................................................................................

Name the check that needs to be used.

...................................................................................................................................................
[2]

(b) State three different types of test data the programmer would need to use. Give an example
of each type and the reason that the programmer chose that test data.

Type 1 .......................................................................................................................................

Example ....................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Type 2 .......................................................................................................................................

Example ....................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Type 3 .......................................................................................................................................

Example ....................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[9]

© UCLES 2019 0478/22/F/M/19 [Turn over


14

6 A database table, BIKETYRES, is used to keep a record of tyres for sale in a cycle shop.
Tyres are categorised by width and diameter in millimetres, whether they have an inner tube and
the type of terrain for which they are designed.

Tyre Code Width Diameter Tube Terrain Stock Level


SLTT 23 700 YES Asphalt 18
MLNT 24 700 NO Asphalt 23
LLNT 28 700 NO Asphalt 19
SLTM 23 700 YES Mixed 22
MLTM 24 700 YES Mixed 14
LLTM 28 700 YES Mixed 12
SLTH 23 700 YES Hard 10
MLTH 24 700 YES Hard 5
LLNH 28 700 NO Hard 7
SLNM 23 700 NO Mixed 12
MLNM 24 700 NO Mixed 22
LLNM 28 700 NO Mixed 18
SSNT 23 650 NO Asphalt 10
MSNT 24 650 NO Asphalt 8
SSTM 23 650 YES Mixed 5
MSNM 24 650 NO Mixed 4

The query-by-example grid below displays the tyre code and the stock level of all 28 mm width
tyres suitable for mixed terrain.

Field: Tyre Code Stock Level Width Terrain


Table: BIKETYRES BIKETYRES BIKETYRES BIKETYRES
Sort:
Show: 3 3
Criteria: = 28 = 'Mixed'
or:

Alter the query to show the tyre code and stock level in ascending order of stock level for all
24 mm asphalt terrain tyres. Write the new query in the following query-by-example grid.

Field:
Table:
Sort:
Show:

Criteria:
or:
[4]
© UCLES 2019 0478/22/F/M/19
8

Section B

2 Describe each of the following data types used in programming. In each case, give an example of
a piece of data to illustrate your answer. Each example must be different.

Char

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

String

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Boolean

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

3 (a) Give an example of a conditional statement using pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Describe the purpose of a conditional statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 2210/21/M/J/19


10

4 This section of program code may be used as a validation check.

1 PRINT "Input a value between 0 and 100 inclusive"


2 INPUT Value
3 WHILE Value < 0 OR Value > 100
4 PRINT "Invalid value, try again"
5 INPUT Value
6 ENDWHILE
7 PRINT "Accepted: ", Value

(a) Give a name for this type of validation check.

............................................................................................................................................. [1]

(b) Describe what is happening in this validation check.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Complete the trace table for this program code using the test data: 200, 300, –1, 50, 60

Value OUTPUT

[3]

© UCLES 2019 2210/21/M/J/19


11

(d) Draw a flowchart to represent this section of program code.

[5]
© UCLES 2019 2210/21/M/J/19 [Turn over
12

5 The table, BEVERAGES, shows the number of calories in 100 ml of a range of popular beverages.
It also shows the availability of these drinks in a can, a small bottle and a large bottle.

BevNo BevName Calories Can Small Bottle Large Bottle


Bev01 Cola 40 Yes Yes Yes
Bev02 Lime 45 Yes No Yes
Bev03 Energy Drink 1 52 Yes Yes No
Bev04 Energy Drink 2 43 Yes No No
Bev05 Mango 47 Yes No Yes
Bev06 Lemon Iced Tea 38 Yes No Yes
Bev07 Lemonade 58 Yes Yes Yes
Bev08 Orange Juice 46 Yes Yes No
Bev12 Apple Juice 50 Yes Yes No
Bev15 Chocolate Milk 83 Yes Yes No

(a) Give a reason for choosing BevNo as the primary key for this table.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) State the number of records shown in the table BEVERAGES.

............................................................................................................................................. [1]

© UCLES 2019 2210/21/M/J/19


13

(c) List the output that would be given by this query-by-example.

Field: BevNo BevName Can Small Bottle Large Bottle

Table: BEVERAGES BEVERAGES BEVERAGES BEVERAGES BEVERAGES

Sort: Descending

Show: ü ü
Criteria: = "Yes" = "Yes" = "Yes"

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(d) Complete the query-by-example grid to output a list showing just the names and primary keys
of all the beverages with a calorie count greater than 45. The list should be in alphabetical
order of names.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]

© UCLES 2019 2210/21/M/J/19


8

Section B

2 (a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.

Count 1
INPUT Number
High Number
Low Count
REPEAT
INPUT Number
IF Number > High
THEN
High Number
ENDIF
IF Number > Low
THEN
Low Number
ENDIF
Count Count + 1
UNTIL Count = 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 2210/22/M/J/19


9

(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 2210/22/M/J/19 [Turn over


10

3 This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.

START

Total 0
Count 0
Distinction 0

INPUT Mark

Is Mark = –1 ? Yes
Total Total + Mark
Count Count + 1

No

No Is OUTPUT "Number of
Mark >= Distinctions ", Distinction
80 ? OUTPUT "Average Mark "
Total/Count
Yes

Distinction Distinction + 1 END

Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45

Total Count Distinction Mark OUTPUT

[4]
© UCLES 2019 2210/22/M/J/19
11

4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition


FOR A 1 TO 100
B B + 1
NEXT A
CASE A OF
100: B A
200: C A
ENDCASE
IF A > 100
THEN
B A
ENDIF
REPEAT
A B * 10
UNTIL A > 100
[4]

5 Explain what is meant by validation and verification.


Give an example for each one.

Validation ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Verification ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 2210/22/M/J/19 [Turn over


12

6 A database table, FLIGHT, is used to keep a record of flights from a small airfield. Planes can
carry passengers, freight or both. Some flights are marked as private and only carry passengers.

Flight number Plane Notes Departure time Passengers


FN101 Caravan 1 Private passenger flight 08:00 Y
CN101 Caravan 2 Freight only 08:30 N
CN102 Piper 1 Freight only 09:00 N
FN104 Piper 2 Passengers only 09:20 Y
FN105 Piper 1 Freight and passengers 10:00 Y
FN106 Caravan 1 Passengers only 10:30 Y
CN108 Caravan 2 Freight only 08:00 N
CN110 Lear Private passenger flight 08:00 Y

(a) State the field that could have a Boolean data type.

Field .................................................................................................................................... [1]

© UCLES 2019 2210/22/M/J/19


13

(b) A query-by-example has been written to display just the flight numbers of all planes leaving
after 10:00 that only carry passengers.

Field: Flight number Passengers Departure time


Table: FLIGHT FLIGHT FLIGHT
Sort:

Show: 3

Criteria: =Y = 10:00
or:

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:

Show:

Criteria:
or:
[7]

© UCLES 2019 2210/22/M/J/19


8

Section B

2 Describe each of the following data types used in programming. In each case, give an example of
a piece of data to illustrate your answer. Each example must be different.

Char

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

String

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Boolean

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

3 (a) Give an example of a conditional statement using pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Describe the purpose of a conditional statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/21/M/J/19


10

4 This section of program code may be used as a validation check.

1 PRINT "Input a value between 0 and 100 inclusive"


2 INPUT Value
3 WHILE Value < 0 OR Value > 100
4 PRINT "Invalid value, try again"
5 INPUT Value
6 ENDWHILE
7 PRINT "Accepted: ", Value

(a) Give a name for this type of validation check.

............................................................................................................................................. [1]

(b) Describe what is happening in this validation check.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Complete the trace table for this program code using the test data: 200, 300, –1, 50, 60

Value OUTPUT

[3]

© UCLES 2019 0478/21/M/J/19


11

(d) Draw a flowchart to represent this section of program code.

[5]
© UCLES 2019 0478/21/M/J/19 [Turn over
12

5 The table, BEVERAGES, shows the number of calories in 100 ml of a range of popular beverages.
It also shows the availability of these drinks in a can, a small bottle and a large bottle.

BevNo BevName Calories Can Small Bottle Large Bottle


Bev01 Cola 40 Yes Yes Yes
Bev02 Lime 45 Yes No Yes
Bev03 Energy Drink 1 52 Yes Yes No
Bev04 Energy Drink 2 43 Yes No No
Bev05 Mango 47 Yes No Yes
Bev06 Lemon Iced Tea 38 Yes No Yes
Bev07 Lemonade 58 Yes Yes Yes
Bev08 Orange Juice 46 Yes Yes No
Bev12 Apple Juice 50 Yes Yes No
Bev15 Chocolate Milk 83 Yes Yes No

(a) Give a reason for choosing BevNo as the primary key for this table.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) State the number of records shown in the table BEVERAGES.

............................................................................................................................................. [1]

© UCLES 2019 0478/21/M/J/19


13

(c) List the output that would be given by this query-by-example.

Field: BevNo BevName Can Small Bottle Large Bottle

Table: BEVERAGES BEVERAGES BEVERAGES BEVERAGES BEVERAGES

Sort: Descending

Show: ü ü
Criteria: = "Yes" = "Yes" = "Yes"

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(d) Complete the query-by-example grid to output a list showing just the names and primary keys
of all the beverages with a calorie count greater than 45. The list should be in alphabetical
order of names.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]

© UCLES 2019 0478/21/M/J/19


8

Section B

2 (a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.

Count 1
INPUT Number
High Number
Low Count
REPEAT
INPUT Number
IF Number > High
THEN
High Number
ENDIF
IF Number > Low
THEN
Low Number
ENDIF
Count Count + 1
UNTIL Count = 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/22/M/J/19


9

(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/22/M/J/19 [Turn over


10

3 This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.

START

Total 0
Count 0
Distinction 0

INPUT Mark

Is Mark = –1 ? Yes
Total Total + Mark
Count Count + 1

No

No Is OUTPUT "Number of
Mark >= Distinctions ", Distinction
80 ? OUTPUT "Average Mark "
Total/Count
Yes

Distinction Distinction + 1 END

Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45

Total Count Distinction Mark OUTPUT

[4]
© UCLES 2019 0478/22/M/J/19
11

4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition


FOR A 1 TO 100
B B + 1
NEXT A
CASE A OF
100: B A
200: C A
ENDCASE
IF A > 100
THEN
B A
ENDIF
REPEAT
A B * 10
UNTIL A > 100
[4]

5 Explain what is meant by validation and verification.


Give an example for each one.

Validation ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Verification ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/22/M/J/19 [Turn over


12

6 A database table, FLIGHT, is used to keep a record of flights from a small airfield. Planes can
carry passengers, freight or both. Some flights are marked as private and only carry passengers.

Flight number Plane Notes Departure time Passengers


FN101 Caravan 1 Private passenger flight 08:00 Y
CN101 Caravan 2 Freight only 08:30 N
CN102 Piper 1 Freight only 09:00 N
FN104 Piper 2 Passengers only 09:20 Y
FN105 Piper 1 Freight and passengers 10:00 Y
FN106 Caravan 1 Passengers only 10:30 Y
CN108 Caravan 2 Freight only 08:00 N
CN110 Lear Private passenger flight 08:00 Y

(a) State the field that could have a Boolean data type.

Field .................................................................................................................................... [1]

© UCLES 2019 0478/22/M/J/19


13

(b) A query-by-example has been written to display just the flight numbers of all planes leaving
after 10:00 that only carry passengers.

Field: Flight number Passengers Departure time


Table: FLIGHT FLIGHT FLIGHT
Sort:

Show: 3

Criteria: =Y = 10:00
or:

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:

Show:

Criteria:
or:
[7]

© UCLES 2019 0478/22/M/J/19


8

Section B

2 (a) An algorithm has been written in pseudocode to input the weight of 500 items and reject any
that are over-weight or under-weight, then print the percentage rejected.
Count 1
Reject 0
Over 62
Under 58
REPEAT
INPUT ItemWeight
IF ItemWeight > Over AND ItemWeight < Under
THEN
Reject Reject - 1
ENDIF
Count Count + 1
UNTIL Count > = 500
Reject Reject / 100
PRINT "Percentage rejected is ", Reject

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/23/M/J/19


9

(b) Describe how you would change the corrected algorithm to calculate the number accepted
instead of rejected, using a variable Accept, and print a warning if fewer than 50% are
accepted.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/23/M/J/19 [Turn over


10

3 This flowchart inputs the tread depth of five tyres, four on the car and a spare tyre. Any tread
depth of 1.6 mm or less is rejected. To be potentially roadworthy, a car must have four tyres with a
tread depth greater than 1.6 mm.

START

TreadReject 0
Count 1

Is Yes
Count = 6?

Count Count + 1 No
Is No
INPUT Depth TreadReject
<= 1?

Yes OUTPUT "Car is


not roadworthy"

No Is
Depth <=
1.6?

Yes

TreadReject TreadReject + 1

OUTPUT "Car is
potentially
roadworthy"

END

© UCLES 2019 0478/23/M/J/19


11

Complete Trace table 1 for the tread depth input data:


1.7, 1.9, 1.4, 1.8, 2.0

TreadReject Count Depth OUTPUT

Trace table 1

Complete Trace table 2 for the tread depth input data:


1.2, 1.9, 1.4, 1.8, 2.4

TreadReject Count Depth OUTPUT

Trace table 2
[4]

© UCLES 2019 0478/23/M/J/19 [Turn over


12

4 For each of the four checks in the table, place a tick in the correct column to show whether it is an
example of a validation or verification check.

Statements Validation Verification


Range check
Double entry
Check digit
Presence check
[4]

5 Identify and describe three loop structures that are available in pseudocode.

Loop structure 1 ...............................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Loop structure 2 ...............................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Loop structure 3 ...............................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/23/M/J/19


14

6 A database table, TRAIN, is used to keep a record of train departures from a station.

Train Number Platform Destination Departure Time Status


1A37 1 Newtown 08:00 On time
2X19 2 Anytown 08:10 Late
1A29 1 Bigcity 08:15 On time
1A28 2 Anytown 08:30 Cancelled
1A67 3 Gardenvillage 08:45 On time
1A37 1 Newtown 08:50 On time
1A24 2 Charter Train 09:00 Late
1A67 3 Gardenvillage 09:15 On time

(a) Explain why the field Train Number could not be used as a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2019 0478/23/M/J/19


15

(b) A query-by-example has been written to display only the train numbers and platforms of all
trains leaving after 08:30 that are late.

Field: Train Number Platform Departure Time Status


Table: TRAIN TRAIN TRAIN TRAIN
Sort:
Show: 3
Criteria: =Y < 08:30
or: = "Late"

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:
Show:
Criteria:
or:
[7]

© UCLES 2019 0478/23/M/J/19


7

Section B

2 An algorithm has been written in pseudocode to select a random number using the function
RandInt(n), which returns a whole number between 1 and the argument n. The algorithm then
allows the user to guess the number.

Number RandInt(100)
TotalTry 1
REPEAT
PRINT "Enter your guess now, it must be a whole number"
INPUT Guess
IF TotalTry > Number
THEN
PRINT "Too large try again"
ENDIF
IF Guess > Number
THEN
PRINT "Too small try again"
ENDIF
TotalTry Guess + 1
UNTIL Guess <> Number
TotalTry TotalTry - 1
PRINT "Number of guesses ", TotalTry

Find the four errors in the pseudocode and suggest a correction to remove each error.

Error 1 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 2 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 3 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 4 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2019 2210/22/O/N/19 [Turn over


8

3 (a) The flowchart checks the lengths of a batch of 10 ropes. For the batch to be accepted 90% of
the lengths need to be between 24.9 and 25.1 metres.

START

Reject 0
Count 0

Yes
Is Count =
10 ?
No
No
Count Count + 1 Is Reject
<= 1 ?
INPUT Length
Yes
OUTPUT "Batch
rejected"

Yes Is Length <


25.1 AND
Length > 24.9 ?

No

Reject Reject + 1

OUTPUT "Batch
accepted"

END

© UCLES 2019 2210/22/O/N/19


9

Complete the trace table for the input data:

24.88, 25.01, 24.98, 25.00, 25.05, 24.99, 24.97, 25.04, 25.19, 25.07

Reject Count Length OUTPUT

[4]

(b) (i) It has been decided to only reject batches of rope that contain ropes that are too short.

State the change required to the algorithm.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Explain how the algorithm to reject batches could be improved to make it more effective.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2019 2210/22/O/N/19 [Turn over


10

4 Four validation checks and four descriptions are shown.

Draw a line to connect each validation check to the correct description.

Validation Check Description

Range check Checks that some data is entered.

Checks for a maximum number of characters


Presence check
in the data entered.

Checks that the characters entered are all


Length check
numbers.

Checks that the value entered is between an


Type check
upper value and a lower value.
[3]

5 A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the weight
and counting the number of baskets. The total weight is stored in a variable Total and the number
of baskets is stored in a variable BasketCount.

Explain, including examples of programming statements, how totalling and counting could be used
in this program.

Totalling .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Counting ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2019 2210/22/O/N/19


11

6 Explain why constants, variables and arrays are used in programming.

Constants .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Variables ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Arrays ...............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 2210/22/O/N/19 [Turn over


12

7 A database table, SALES, is used to keep a record of items made and sold by a furniture maker.

Item number Order number Notes Amount Status


CH001 1921 Smith – six dining chairs 6 Delivered
TB003 1921 Smith – large table 1 In progress
CH001 1924 Hue – extra chairs 4 In progress
CH003 1925 For stock 2 Cancelled
BN001 1927 Patel – replacement bench 1 Not started
ST002 1931 Sola – small table 1 Delivered
CH003 1927 Patel – eight dining chairs with arms 8 Not started
TB003 1927 Patel – large table 1 Not started

(a) Explain why the field Item number could not be used as a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2019 2210/22/O/N/19


13

(b) A query-by-example has been written to display only the order number and item numbers of
any items in progress or not started.

Field: Item number Order number Amount Status


Table: SALES SALES SALES SALES
Sort:
Show: 3 3
Criteria: Not Like "Delivered"
or:

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2019 2210/22/O/N/19


8

Section B

2 For each of the four descriptions in the table, place a tick in the correct column to show whether it
describes a Structure diagram, a Flowchart or Library routines.

Structure Library
Description diagram Flowchart routines
A modelling tool used to show the hierarchy of a
system.
A collection of standard programs available for
immediate use.
A graphical representation used to represent an
algorithm.
A graphical representation to show how a system is
broken into sub-systems.
[4]

3 Examine the following pseudocode:

INPUT A
INPUT B
INPUT C
INPUT D
INPUT E
INPUT F
INPUT G
INPUT H
INPUT I
INPUT J
INPUT K
INPUT L
T A + B + C + D + E + F + G + H + I + J + K + L
OUTPUT "The average equals ", T / 12

(a) Describe what happens in this pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2019 0478/21/O/N/19


9

(b) Describe how this pseudocode could be altered to allow any number of values to be input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) Re-write the given pseudocode to allow any number of values to be input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2019 0478/21/O/N/19 [Turn over


10

4 (a) Complete the trace table for this algorithm using the given input data.

Index 0
FOR Count 0 TO 7
INPUT Value
IF Value > 50
THEN
PassMarks[Index] Value
Index Index + 1
ENDIF
NEXT Count
PRINT "Number passed ", Index

Input data: 58, 40, 67, 85, 12, 13, 75, 82

PassMarks
OUTPUT
Index Count Value [0] [1] [2] [3] [4] [5] [6] [7]

[6]

(b) Give the purpose of the algorithm shown in part (a).

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2019 0478/21/O/N/19


11

5 A car manufacturer makes a range of car models named Pegasus, Apollo and Cupid. It keeps a
database to store the records of its range and the different options for each car model. Within the
table CAR_RANGE, the following data needs to be stored:

1. Car model
2. Body style – saloon, hatchback or estate
3. How many doors it has
4. Whether it uses petrol, diesel or batteries as fuel
5. An identifier for a specific car.

(a) Complete the table to show suitable field names and an example of appropriate data for each
field in the database table CAR_RANGE.

Field name Example of data

[3]

(b) State which of your fields would be most appropriate for a primary key and give a reason for
your choice.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Complete the query-by-example grid to provide a list of car models using petrol and the
number of doors these cars have, in alphabetical order of car model. Display only the car
models and the number of doors.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2019 0478/21/O/N/19


7

Section B

2 An algorithm has been written in pseudocode to select a random number using the function
RandInt(n), which returns a whole number between 1 and the argument n. The algorithm then
allows the user to guess the number.

Number RandInt(100)
TotalTry 1
REPEAT
PRINT "Enter your guess now, it must be a whole number"
INPUT Guess
IF TotalTry > Number
THEN
PRINT "Too large try again"
ENDIF
IF Guess > Number
THEN
PRINT "Too small try again"
ENDIF
TotalTry Guess + 1
UNTIL Guess <> Number
TotalTry TotalTry - 1
PRINT "Number of guesses ", TotalTry

Find the four errors in the pseudocode and suggest a correction to remove each error.

Error 1 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 2 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 3 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 4 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2019 0478/22/O/N/19 [Turn over


8

3 (a) The flowchart checks the lengths of a batch of 10 ropes. For the batch to be accepted 90% of
the lengths need to be between 24.9 and 25.1 metres.

START

Reject 0
Count 0

Yes
Is Count =
10 ?
No
No
Count Count + 1 Is Reject
<= 1 ?
INPUT Length
Yes
OUTPUT "Batch
rejected"

Yes Is Length <


25.1 AND
Length > 24.9 ?

No

Reject Reject + 1

OUTPUT "Batch
accepted"

END

© UCLES 2019 0478/22/O/N/19


9

Complete the trace table for the input data:

24.88, 25.01, 24.98, 25.00, 25.05, 24.99, 24.97, 25.04, 25.19, 25.07

Reject Count Length OUTPUT

[4]

(b) (i) It has been decided to only reject batches of rope that contain ropes that are too short.

State the change required to the algorithm.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Explain how the algorithm to reject batches could be improved to make it more effective.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2019 0478/22/O/N/19 [Turn over


10

4 Four validation checks and four descriptions are shown.

Draw a line to connect each validation check to the correct description.

Validation Check Description

Range check Checks that some data is entered.

Checks for a maximum number of characters


Presence check
in the data entered.

Checks that the characters entered are all


Length check
numbers.

Checks that the value entered is between an


Type check
upper value and a lower value.
[3]

5 A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the weight
and counting the number of baskets. The total weight is stored in a variable Total and the number
of baskets is stored in a variable BasketCount.

Explain, including examples of programming statements, how totalling and counting could be used
in this program.

Totalling .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Counting ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2019 0478/22/O/N/19


11

6 Explain why constants, variables and arrays are used in programming.

Constants .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Variables ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Arrays ...............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/22/O/N/19 [Turn over


12

7 A database table, SALES, is used to keep a record of items made and sold by a furniture maker.

Item number Order number Notes Amount Status


CH001 1921 Smith – six dining chairs 6 Delivered
TB003 1921 Smith – large table 1 In progress
CH001 1924 Hue – extra chairs 4 In progress
CH003 1925 For stock 2 Cancelled
BN001 1927 Patel – replacement bench 1 Not started
ST002 1931 Sola – small table 1 Delivered
CH003 1927 Patel – eight dining chairs with arms 8 Not started
TB003 1927 Patel – large table 1 Not started

(a) Explain why the field Item number could not be used as a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2019 0478/22/O/N/19


13

(b) A query-by-example has been written to display only the order number and item numbers of
any items in progress or not started.

Field: Item number Order number Amount Status


Table: SALES SALES SALES SALES
Sort:
Show: 3 3
Criteria: Not Like "Delivered"
or:

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2019 0478/22/O/N/19


8

Section B

2 Describe the use of a subroutine in a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

3 Name the three types of loop structure used in pseudocode.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2019 0478/23/O/N/19


9

4 The following pseudocode algorithm uses nested IF statements.

IF Response = 1
THEN
X X + Y
ELSE
IF Response = 2
THEN
X X – Y
ELSE
IF Response = 3
THEN
X X * Y
ELSE
IF Response = 4
THEN
X X / Y
ELSE
OUTPUT "No response"
ENDIF
ENDIF
ENDIF
ENDIF

(a) Name the type of statement demonstrated by the use of IF … THEN … ELSE … ENDIF

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Re-write the pseudocode algorithm using a CASE statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/23/O/N/19 [Turn over


10

5 The algorithm performs an operation on the array named MyData

DIV means integer division, so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3

First 0
Last 16
Found FALSE
INPUT UserIn
WHILE (First <= Last) AND (Found = FALSE) DO
Middle (First + Last) DIV 2
IF MyData[Middle] = UserIn
THEN
Found TRUE
ELSE
IF UserIn < MyData[Middle]
THEN
Last Middle - 1
ELSE
First Middle + 1
ENDIF
ENDIF
ENDWHILE
OUTPUT Found

This table shows the contents of the array: MyData e.g. MyData[2] stores the value 5

MyData
Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
Value 2 3 5 6 8 10 12 13 14 16 18 20 25 27 29 34 36

(a) Complete the trace table for the input data: 10

First Last UserIn Middle Found OUTPUT

[6]

(b) Describe the function being performed by the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
© UCLES 2019 0478/23/O/N/19
11

6 Draw four different flowchart symbols and describe how they are used in a program flowchart.

Flowchart symbol Description of use

[4]

© UCLES 2019 0478/23/O/N/19 [Turn over


12

7 A teacher has decided to use a database table as her mark book for her Computer Science class,
which she has called MARKBOOK. For each student, the following data will be recorded: first
name, last name, their year 10 test score and their year 11 test score. The class has 32 students.

(a) State the number of fields and records required for this database.

Number of Fields ......................................................................................................................

Number of Records ..................................................................................................................


[2]

(b) The data in MARKBOOK is stored under category headings: LastName, FirstName,
Y10TestScore and Y11TestScore.

State, with a reason, whether any of these headings would be suitable as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Complete the query-by-example grid to only display the first name, last name and year 10
test score of each student who achieved 50 or more in their year 10 test. The output should
be in test score order with the highest marks at the top of the list.

Field:

Table:

Sort:

Show:
Criteria:

or:
[4]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2019 0478/23/O/N/19


8

Section B

2 Describe the use of a subroutine in a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

3 Name the three types of loop structure used in pseudocode.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2019 2210/23/O/N/19


9

4 The following pseudocode algorithm uses nested IF statements.

IF Response = 1
THEN
X X + Y
ELSE
IF Response = 2
THEN
X X – Y
ELSE
IF Response = 3
THEN
X X * Y
ELSE
IF Response = 4
THEN
X X / Y
ELSE
OUTPUT "No response"
ENDIF
ENDIF
ENDIF
ENDIF

(a) Name the type of statement demonstrated by the use of IF … THEN … ELSE … ENDIF

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Re-write the pseudocode algorithm using a CASE statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 2210/23/O/N/19 [Turn over


10

5 The algorithm performs an operation on the array named MyData

DIV means integer division, so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3

First 0
Last 16
Found FALSE
INPUT UserIn
WHILE (First <= Last) AND (Found = FALSE) DO
Middle (First + Last) DIV 2
IF MyData[Middle] = UserIn
THEN
Found TRUE
ELSE
IF UserIn < MyData[Middle]
THEN
Last Middle - 1
ELSE
First Middle + 1
ENDIF
ENDIF
ENDWHILE
OUTPUT Found

This table shows the contents of the array: MyData e.g. MyData[2] stores the value 5

MyData
Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
Value 2 3 5 6 8 10 12 13 14 16 18 20 25 27 29 34 36

(a) Complete the trace table for the input data: 10

First Last UserIn Middle Found OUTPUT

[6]

(b) Describe the function being performed by the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
© UCLES 2019 2210/23/O/N/19
11

6 Draw four different flowchart symbols and describe how they are used in a program flowchart.

Flowchart symbol Description of use

[4]

© UCLES 2019 2210/23/O/N/19 [Turn over


12

7 A teacher has decided to use a database table as her mark book for her Computer Science class,
which she has called MARKBOOK. For each student, the following data will be recorded: first
name, last name, their year 10 test score and their year 11 test score. The class has 32 students.

(a) State the number of fields and records required for this database.

Number of Fields ......................................................................................................................

Number of Records ..................................................................................................................


[2]

(b) The data in MARKBOOK is stored under category headings: LastName, FirstName,
Y10TestScore and Y11TestScore.

State, with a reason, whether any of these headings would be suitable as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Complete the query-by-example grid to only display the first name, last name and year 10
test score of each student who achieved 50 or more in their year 10 test. The output should
be in test score order with the highest marks at the top of the list.

Field:

Table:

Sort:

Show:
Criteria:

or:
[4]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2019 2210/23/O/N/19


7

Section B

2 An algorithm has been written in pseudocode to input some numbers and print out any numbers
that are greater than or equal to 100. The number 999 stops the algorithm.

INPUT Number
WHILE NUMBERS <> 999 DO
IF Number > 100 THEN PRINT Number ENDIF
ENDWHILE
PRINT Number

(a) Find the four errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(b) Show, using pseudocode, how you would change the corrected algorithm to print out any
numbers between 100 and 200 inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]
© UCLES 2018 0478/22/F/M/18 [Turn over
8

3 This flowchart inputs the weight in kilograms of a passenger stepping into a lift. The lift can take a
maximum of eight passengers or a maximum weight of 640 kilograms.

START

totalWeight 0
totalNumber 0

INPUT Weight

totalWeight totalWeight + Weight


totalNumber totalNumber + 1

Is
Yes
totalWeight
> 640?

No

No Is
Yes
totalNumber
> 8?

OUTPUT 'Lift
overload, step
out'

END

© UCLES 2018 0478/22/F/M/18


9

Complete the trace table for the passenger input data:

50, 70, 65, 100, 95, 50, 55, 85, 70, 75

Weight totalWeight totalNumber OUTPUT

[4]

© UCLES 2018 0478/22/F/M/18 [Turn over


10

4 A program checks if the weight of a baby is at least 2 kilograms.

Give, with reasons, two different values of test data that could be used for the baby’s weight.
Each reason must be different.

Value 1 .............................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Value 2 .............................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................
[4]

5 Explain the difference between the programming concepts of sequence and selection. Include
an example of a programming statement for each concept in your explanation.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2018 0478/22/F/M/18


11

6 A database table, JEWEL, is used to keep a record of jewellery for sale in a shop. Each item of
jewellery can be made of silver, platinum or gold metal. The shop stocks rings, bracelets and
necklaces. The number in stock and the price is also stored.

(a) Identify the four fields required for the database. Give each field a suitable name and data
type. Explain why you chose the data type for each field.

Field 1 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................

Field 2 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................

Field 3 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................

Field 4 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................
[8]

(b) Explain why none of these fields could be used as a primary key.

...................................................................................................................................................

...............................................................................................................................................[1]

(c) Using the query-by-example grid below, write a query to identify the silver bracelets. Only
display the number in stock and the price.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2018 0478/22/F/M/18


6

Section B

2 (a) Write an algorithm to input 1000 numbers. Count how many numbers are positive and how
many numbers are zero. Then output the results. Use either pseudocode or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [6]
© UCLES 2018 2210/21/M/J/18
7

(b) Give one change you could make to your algorithm to ensure initial testing is more
manageable.

...................................................................................................................................................

.............................................................................................................................................. [1]

Question 3 starts on page 8.

© UCLES 2018 2210/21/M/J/18 [Turn over


8

3 The global trade item number (GTIN-8) barcode has seven digits and a check digit.
This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the
GTIN-8.
DIV(X,Y), finds the number of divides in division for example DIV(23,10) is 2.
MOD(X,Y), finds the remainder in division for example MOD(23,10) is 3.

FOR Count 1 TO 7
INPUT Number
Digit(Count) Number
NEXT
Sum (Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6)
IF MOD(Sum,10) <> 0
THEN Digit(8) DIV(Sum,10)*10 + 10 - Sum
ELSE Digit(8) 0
ENDIF
OUTPUT "GTIN-8"
FOR Count 1 TO 8
OUTPUT Digit(Count)
NEXT

(a) Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4

Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8) Sum OUTPUT

Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1

Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8) Sum OUTPUT

[5]

© UCLES 2018 2210/21/M/J/18


9

(b) Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

Question 4 starts on page 10.

© UCLES 2018 2210/21/M/J/18 [Turn over


10

4 A programmer has written a routine to check that prices are below $10.00. These values are used
as test data.

10.00 9.99 ten

Explain why each value was chosen.

10.00 ................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

9.99 ..................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ten ....................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

5 Explain the difference between the programming concepts of counting and totalling.
Include an example of a programming statement for each concept in your explanation.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [4]

© UCLES 2018 2210/21/M/J/18


11

6 A database table, PERFORMANCE, is used to keep a record of the performances at a local


theatre.

Show Number Type Title Date Sold Out


SN091 Comedy An Evening at Home 01 Sept Yes
SN102 Drama Old Places 02 Oct No
SN113 Jazz Acoustic Evening 03 Nov No
SN124 Classical Mozart Evening 04 Dec Yes
SN021 Classical Bach Favourites 01 Feb Yes
SN032 Jazz 30 Years of Jazz 02 Mar Yes
SN043 Comedy Street Night 03 Apr No
SN054 Comedy Hoot 04 May No

(a) State the number of fields and records in the table.

Fields ........................................................................................................................................

Records ....................................................................................................................................
[2]

(b) Give two validation checks that could be performed on the Show Number field.

Validation check 1 .....................................................................................................................

...................................................................................................................................................

Validation check 2 .....................................................................................................................

...................................................................................................................................................
[2]

(c) Using the query-by-example grid, write a query to identify jazz performances that are not sold
out. Only display the date and the title.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2018 2210/21/M/J/18


6

Section B

2 (a) Write an algorithm to input 1000 numbers. Count how many numbers are positive and how
many numbers are zero. Then output the results. Use either pseudocode or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [6]
© UCLES 2018 0478/21/M/J/18
7

(b) Give one change you could make to your algorithm to ensure initial testing is more
manageable.

...................................................................................................................................................

.............................................................................................................................................. [1]

Question 3 starts on page 8.

© UCLES 2018 0478/21/M/J/18 [Turn over


8

3 The global trade item number (GTIN-8) barcode has seven digits and a check digit.
This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the
GTIN-8.
DIV(X,Y), finds the number of divides in division for example DIV(23,10) is 2.
MOD(X,Y), finds the remainder in division for example MOD(23,10) is 3.

FOR Count 1 TO 7
INPUT Number
Digit(Count) Number
NEXT
Sum (Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6)
IF MOD(Sum,10) <> 0
THEN Digit(8) DIV(Sum,10)*10 + 10 - Sum
ELSE Digit(8) 0
ENDIF
OUTPUT "GTIN-8"
FOR Count 1 TO 8
OUTPUT Digit(Count)
NEXT

(a) Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4

Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8) Sum OUTPUT

Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1

Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8) Sum OUTPUT

[5]

© UCLES 2018 0478/21/M/J/18


9

(b) Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

Question 4 starts on page 10.

© UCLES 2018 0478/21/M/J/18 [Turn over


10

4 A programmer has written a routine to check that prices are below $10.00. These values are used
as test data.

10.00 9.99 ten

Explain why each value was chosen.

10.00 ................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

9.99 ..................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ten ....................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

5 Explain the difference between the programming concepts of counting and totalling.
Include an example of a programming statement for each concept in your explanation.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [4]

© UCLES 2018 0478/21/M/J/18


11

6 A database table, PERFORMANCE, is used to keep a record of the performances at a local


theatre.

Show Number Type Title Date Sold Out


SN091 Comedy An Evening at Home 01 Sept Yes
SN102 Drama Old Places 02 Oct No
SN113 Jazz Acoustic Evening 03 Nov No
SN124 Classical Mozart Evening 04 Dec Yes
SN021 Classical Bach Favourites 01 Feb Yes
SN032 Jazz 30 Years of Jazz 02 Mar Yes
SN043 Comedy Street Night 03 Apr No
SN054 Comedy Hoot 04 May No

(a) State the number of fields and records in the table.

Fields ........................................................................................................................................

Records ....................................................................................................................................
[2]

(b) Give two validation checks that could be performed on the Show Number field.

Validation check 1 .....................................................................................................................

...................................................................................................................................................

Validation check 2 .....................................................................................................................

...................................................................................................................................................
[2]

(c) Using the query-by-example grid, write a query to identify jazz performances that are not sold
out. Only display the date and the title.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2018 0478/21/M/J/18


6

Section B

2 (a) Draw a flowchart for an algorithm to input numbers. Reject any numbers that are negative
and count how many numbers are positive. When the number zero is input, the process ends
and the count of positive numbers is output.

[6]
© UCLES 2018 0478/22/M/J/18
7

(b) Explain the changes you will make to your algorithm to also count the negative numbers.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

Question 3 starts on Page 8.

© UCLES 2018 0478/22/M/J/18 [Turn over


8

3 This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the
calculation shown by the sign. An input of zero for the first number terminates the process.

INPUT Number1, Number2, Sign


WHILE Number1 <> 0
IF Sign = '+' THEN Answer Number1 + Number2 ENDIF
IF Sign = '-' THEN Answer Number1 - Number2 ENDIF
IF Sign = '*' THEN Answer Number1 * Number2 ENDIF
IF Sign = '/' THEN Answer Number1 / Number2 ENDIF
IF Sign <> '/' AND Sign <> '*' AND Sign <> '-' AND Sign <> '+'
THEN Answer 0
ENDIF
IF Answer <> 0 THEN OUTPUT Answer ENDIF
INPUT Number1, Number2, Sign
ENDWHILE

(a) Complete the trace table for the input data:


*
5, 7, +, 6, 2, –, 4, 3, , 7, 8, ?, 0, 0, /

Number1 Number2 Sign Answer OUTPUT

[3]

(b) Show how you could improve the algorithm written in pseudocode by writing an alternative
type of conditional statement in pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2018 0478/22/M/J/18


9

4 A programmer has written a routine to store the name, email address and password of a contributor
to a website’s discussion group.

(a) The programmer has chosen to verify the name, email address and password.

Explain why verification was chosen and describe how the programmer would verify this data.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(b) The programmer has also decided to validate the email address and the password.

Describe validation checks that could be used.

Email address ............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Password ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2018 0478/22/M/J/18 [Turn over


10

5 A program checks that the weight of a basket of fruit is over 1.00 kilograms and under
1.10 kilograms. Weights are recorded to an accuracy of two decimal places and any weight not in
this form has already been rejected.

Give three weights as test data and for each weight state a reason for choosing it. All your reasons
must be different.

Weight 1 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................

Weight 2 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................

Weight 3 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2018 0478/22/M/J/18


11

6 A database table, TREES, is used to keep a record of the trees in a park. Each tree is given a
unique number and is examined to see if it is at risk of dying. There are over 900 trees; part of the
database table is shown.

Tree Number Type Map Position Age in Years At Risk


TN091 Acacia A7 250 Y
TN172 Olive C5 110 N
TN913 Cedar B9 8 N
TN824 Banyan A3 50 Y
TN021 Pine D5 560 Y
TN532 Teak C8 76 Y
TN043 Yew B1 340 N
TN354 Spruce D4 65 N
TN731 Elm B10 22 Y
TN869 Oak C9 13 N
TN954 Pine E11 3 N

(a) State the number of fields in the table.

...............................................................................................................................................[1]

(b) The tree numbering system uses TN followed by three digits. The numbering system will not
work if there are over 1000 trees.
Describe, with the aid of an example, how you could change the tree numbering system to
allow for over 1000 trees. Existing tree numbers must not be changed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Using the query-by-example grid, write a query to identify at risk trees over 100 years old.
Display only the type and the position on the map.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
© UCLES 2018 0478/22/M/J/18
6

Section B

2 Describe, using an example, the purpose of the following checks during data entry.

(a) Validation check

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Verification check

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

3 This section of program code reads the contents of the array, totals the numbers and prints out the
sum and average of the numbers. Assume the array is full.

Complete the four missing items by writing them in the spaces provided in this code.

1 Numbers[1:30]

2 Total = 0

3 .............................................. = 0

4 FOR Count = 1 TO .........................................................

5 Number = Numbers[Count]

6 Total = ......................................................... + Number

7 Counter = Counter + 1

8 .................................................................................................. Count

9 PRINT ′The sum of the numbers you entered is ′, Total

10 PRINT ′The average of the numbers you entered is ′, Total / Counter


[4]

© UCLES 2018 0478/23/M/J/18


7

4 An algorithm is written in pseudocode:

INPUT Number
IF Number > 100
THEN OUTPUT ″The number is too large″
ELSE OUTPUT ″The number is acceptable″
ENDIF

(a) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) (i) The algorithm only allows one attempt at inputting an acceptable value.

State how you would change the algorithm so that it continues until a suitable input is
supplied.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Re-write the algorithm in full, using pseudocode, to implement your answer to part (b)(i).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2018 0478/23/M/J/18 [Turn over


8

5 The flowchart allows a set of 10 numbers to be entered; it finds and outputs the largest of these
numbers.

START

Max –1000.00
Counter 0

INPUT Num

Yes Is Num >


Max ?

No
Max Num

Counter Counter + 1

Is Counter Yes
< 10 ?

No

OUTPUT Max

END

© UCLES 2018 0478/23/M/J/18


9

(a) Complete the trace table for the input data:

6.30, 18.62, 50.01, 3.13, 2.05, 50.10, 40.35, 30.69, 0.85, 17.30

Max Counter Num OUTPUT

[3]

(b) Describe two different changes you should make to the flowchart to find the smallest number
instead of the largest number.

Change 1 ...................................................................................................................................

...................................................................................................................................................

Change 2 ...................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2018 0478/23/M/J/18 [Turn over


10

6 A shop that sells copies of movies to the public has set up a new database table called 2018MOV
to store some new releases. Part of this table is given, showing the catalogue number, title, genres
and available formats (Blu-ray, DVD or streaming) of each movie.

CatNo Title Genre 1 Genre 2 Blu-ray DVD Stream


18m01 Battery Rangers Adventure Fantasy Yes No Yes
18m02 Golfwatch Comedy Drama Yes No Yes
18m03 Chair 27 Comedy Drama Yes Yes No
18m04 Wander Woman Action Fantasy Yes No Yes
18m05 Justine League Action Fantasy Yes Yes Yes
18m06 That Horror Thriller Yes Yes No
18m07 Insect Dude Action Fantasy No Yes No
18m08 Dover Beach Action History No Yes No
18m12 Slow 25 Action Thriller No Yes No
18m15 Kongkers Adventure Fantasy No Yes No
18m16 Transducers: The Last Night Action Sci-Fi Yes Yes Yes
18m17 The Pale Tower Fantasy Sci-Fi Yes Yes No
18m19 Bea and the Bute Fantasy Romance Yes Yes Yes
18m21 The Daddy Action Fantasy No No Yes
18m22 Planet Wars: Episode X Sci-Fi Action Yes No Yes
18m23 Guardians of the Milky Way Action Sci-Fi Yes Yes Yes
18m26 Odin Horror Sci-Fi No Yes Yes
18m27 That Fantasy Sci-Fi No No Yes
18m30 Underneath Action Horror Yes No No
18m31 Debatable Me Animation Action Yes Yes No

(a) State the number of records in this part of the table.

...............................................................................................................................................[1]

(b) (i) Give the name of the field that should be used for the primary key.

.......................................................................................................................................[1]

(ii) State the reason for choosing this field for the primary key.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2018 0478/23/M/J/18


11

(c) Complete the table to show the most appropriate data type for each field based on the data
shown in the table at the start of question 6.

Field Data type


CatNo
Title
Genre 1
Stream
[2]

(d) List the output that would be given by this query-by-example.

Field: CatNo Title Genre 1 Blu-ray DVD Stream


Table: 2018MOV 2018MOV 2018MOV 2018MOV 2018MOV 2018MOV
Sort:
Show: 3 3 3 3 3
Criteria: =“Comedy”
or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(e) Using the query-by-example grid, write a query to identify all the movies that are categorised
as Sci-Fi and available to stream. Only display the catalogue number and title of the film, with
the titles listed in alphabetical order.

Field:
Table:
Sort:
Show:
Criteria:
or:

[4]

© UCLES 2018 0478/23/M/J/18


6

Section B

2 (a) Draw a flowchart for an algorithm to input numbers. Reject any numbers that are negative
and count how many numbers are positive. When the number zero is input, the process ends
and the count of positive numbers is output.

[6]
© UCLES 2018 2210/22/M/J/18
7

(b) Explain the changes you will make to your algorithm to also count the negative numbers.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

Question 3 starts on Page 8.

© UCLES 2018 2210/22/M/J/18 [Turn over


8

3 This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the
calculation shown by the sign. An input of zero for the first number terminates the process.

INPUT Number1, Number2, Sign


WHILE Number1 <> 0
IF Sign = '+' THEN Answer Number1 + Number2 ENDIF
IF Sign = '-' THEN Answer Number1 - Number2 ENDIF
IF Sign = '*' THEN Answer Number1 * Number2 ENDIF
IF Sign = '/' THEN Answer Number1 / Number2 ENDIF
IF Sign <> '/' AND Sign <> '*' AND Sign <> '-' AND Sign <> '+'
THEN Answer 0
ENDIF
IF Answer <> 0 THEN OUTPUT Answer ENDIF
INPUT Number1, Number2, Sign
ENDWHILE

(a) Complete the trace table for the input data:


*
5, 7, +, 6, 2, –, 4, 3, , 7, 8, ?, 0, 0, /

Number1 Number2 Sign Answer OUTPUT

[3]

(b) Show how you could improve the algorithm written in pseudocode by writing an alternative
type of conditional statement in pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2018 2210/22/M/J/18


9

4 A programmer has written a routine to store the name, email address and password of a contributor
to a website’s discussion group.

(a) The programmer has chosen to verify the name, email address and password.

Explain why verification was chosen and describe how the programmer would verify this data.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(b) The programmer has also decided to validate the email address and the password.

Describe validation checks that could be used.

Email address ............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Password ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2018 2210/22/M/J/18 [Turn over


10

5 A program checks that the weight of a basket of fruit is over 1.00 kilograms and under
1.10 kilograms. Weights are recorded to an accuracy of two decimal places and any weight not in
this form has already been rejected.

Give three weights as test data and for each weight state a reason for choosing it. All your reasons
must be different.

Weight 1 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................

Weight 2 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................

Weight 3 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2018 2210/22/M/J/18


11

6 A database table, TREES, is used to keep a record of the trees in a park. Each tree is given a
unique number and is examined to see if it is at risk of dying. There are over 900 trees; part of the
database table is shown.

Tree Number Type Map Position Age in Years At Risk


TN091 Acacia A7 250 Y
TN172 Olive C5 110 N
TN913 Cedar B9 8 N
TN824 Banyan A3 50 Y
TN021 Pine D5 560 Y
TN532 Teak C8 76 Y
TN043 Yew B1 340 N
TN354 Spruce D4 65 N
TN731 Elm B10 22 Y
TN869 Oak C9 13 N
TN954 Pine E11 3 N

(a) State the number of fields in the table.

...............................................................................................................................................[1]

(b) The tree numbering system uses TN followed by three digits. The numbering system will not
work if there are over 1000 trees.
Describe, with the aid of an example, how you could change the tree numbering system to
allow for over 1000 trees. Existing tree numbers must not be changed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Using the query-by-example grid, write a query to identify at risk trees over 100 years old.
Display only the type and the position on the map.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
© UCLES 2018 2210/22/M/J/18
8

Section B

2 Six terms associated with programming and six descriptions are listed.

Draw a line to link each term with its most appropriate description.

Term Description

Pre-written code to include in


Top-down design your own program to carry out
a common task.

Shows the steps representing


Structure diagram an algorithm using various
shapes of boxes.

Shows the hierarchy of the


Flowchart different components which
make up a system.

Shows the values of variables


Pseudocode as you manually test your
program.

Breaks down a system into


Library routine
successively smaller pieces.

Describes a program using a


Trace table
simplified high-level notation.

[5]

© UCLES 2018 0478/21/O/N/18


9

3 Describe, giving a different example for each, the purpose of these validation checks used in
programming.

Range check ....................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Length check ....................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Type check .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2018 0478/21/O/N/18 [Turn over


10

4 An algorithm is written in pseudocode:

Total 0
FOR Count 1 TO 50
INPUT Num
Total Total + Num
NEXT Count
OUTPUT Total

(a) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(b) Re-write the algorithm in pseudocode using a different type of loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) Describe how you could modify the original algorithm shown at the start of question 4, to
allow any number of inputs.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2018 0478/21/O/N/18


12

5 The flowchart performs a mathematical process on a number input called TestNum

DIV is used to represent integer division e.g. 7 DIV 3 = 2

START

Flag True

INPUT
TestNum

Num TestNum – 1

Yes Is Num = No
1?

Num Num – 1

Yes Is TestNum / No
Flag False Num = TestNum
DIV Num ?

Is Flag = Yes
True ?

No

OUTPUT
TestNum

END

© UCLES 2018 0478/21/O/N/18


13

(a) Complete the trace table for the input data: 7

Flag TestNum Num OUTPUT

[2]

(b) Complete the trace table for the input data: 6

Flag TestNum Num OUTPUT

[2]

(c) State the purpose of the algorithm in the flowchart.

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2018 0478/21/O/N/18 [Turn over


14

6 The database table, PCSTOCK, is a part of the database in an electronics shop, showing some of
the desktop (DT), tablet (TB) and laptop (LT) computers they have in stock.

PCID ScreenSize RAM Type HDD(GB) Price


DT303240 30 32 DT 4000 $5000.00
DT303220 30 32 DT 2000 $4500.00
DT301620 30 16 DT 2000 $4000.00
DT231610 23 16 DT 1000 $3000.00
LT191620 19 16 LT 2000 $3000.00
LT171610 17 16 LT 1000 $2500.00
DT230820 23 8 DT 2000 $2000.00
DT190810 19 8 DT 1000 $1500.00
LT190810 19 8 LT 1000 $1500.00
LT170805 17 8 LT 500 $1200.00
DT230420 23 4 DT 2000 $1000.00
DT190410 19 4 DT 1000 $750.00
LT190410 19 4 LT 1000 $950.00
TB100206 10 2 TB 64 $200.00

(a) Complete the table to show the most appropriate data type for each field based on the data
shown in the table at the start of question 6.

Field Data type


PCID
ScreenSize
Type
Price
[2]

(b) Using the query-by-example grid, write a query to identify all the desktop computers with a
hard drive larger than 1000 GB. All fields in the table should be shown, sorted in descending
order by price.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2018 0478/21/O/N/18


7

Section B

2 (a) Write an algorithm, using pseudocode, to input three different numbers, multiply the two
larger numbers together and output the result. Use the variables: Number1, Number2 and
Number3 for your numbers and Answer for your result.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.

Test data set 1 ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Test data set 2 ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2018 0478/22/O/N/18 [Turn over


8

3 Four programming concepts and four descriptions are shown.


Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description


A subroutine that does not
Library routine
have to return a value.

Structure A standard subroutine that is


diagram available for immediate use.

A subroutine that always


Procedure
returns a value.

An overview of a program or
Function
subroutine.
[3]

4 A programmer wants to test that the readings from 2000 electricity meters are greater than 400
units and less than 900 units. The programmer uses selection and repetition statements as part of
the program.
Explain, using programming statements, how selection and repetition could be used in this
program.

Selection ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Repetition .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2018 0478/22/O/N/18


10

5 The flowchart checks the level of chlorine and the depth of water compared to the height of the
swimming pool. Error messages are output if a problem is found.

START

INPUT Height,
Depth, Chlorine

OK True

OUTPUT
Is Depth > Yes
"Water too
Height/2 ? deep"

No
OUTPUT
Is Depth < Yes "Water too
Height/3 ? shallow"

No
OK False

Yes OUTPUT "Too


Is Chlorine much chlorine
>3 ? add more water"
No

OUTPUT "Too
Yes little chlorine
Is Chlorine
<1 ? add more chlorine"
No

No
Is OK = True ?

Yes

OUTPUT "Pool OK
to use"

END

© UCLES 2018 0478/22/O/N/18


11

(a) Complete the trace tables for each set of input data.

Input data: 6, 2.5, 2

Height Depth Chlorine OK OUTPUT

Input data: 4, 3, 1.5

Height Depth Chlorine OK OUTPUT

Input data: 6, 3.5, 4

Height Depth Chlorine OK OUTPUT

[6]

(b) Identify a problem with the algorithm that the flowchart represents.

...................................................................................................................................................

.............................................................................................................................................. [1]

© UCLES 2018 0478/22/O/N/18 [Turn over


12

6 A database table, PORTRAIT, is used to keep a record of the portraits available from a photographic
studio. Each portrait has a unique reference number PICnnn, where n is a single digit, for example
PIC123. The studio keeps a record of the size (for example 20 × 15), the type (black and white or
colour), and the price in dollars.

(a) Complete the table to show the most appropriate data type for each of the fields.

Field Data type

Reference Number

Size

Type

Price in $
[4]

(b) The results from the query-by-example grid should show the reference number, price, type
and size of all portraits under $50. Identify the three errors in the query-by-example grid.

Field: Reference No Price in $ Type Size

Table: PORTRAIT PORTRAIT PORTRAIT PORTRAIT

Sort:

Show:   
Criteria: >50.00

or:

Error 1 .......................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................
[3]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2018 0478/22/O/N/18


7

Section B

2 Describe, giving an example for each, the following data types used in programming.

Integer

Description ........................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

String

Description ........................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................
[4]

3 Give an example of a pseudocode statement or statements to perform each of the following


functions.

A condition controlled loop ...............................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

A conditional statement ....................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Totalling ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2018 0478/23/O/N/18 [Turn over


8

4 This is a section of program code.

1 Total = 100.00
2
PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4 PRINT ′Enter a height in metres′
5 INPUT Height
6 Total = Total + Height
7 PRINT Total / 30
8 Count = Count + 1
9 NEXT Count

(a) There are three errors in this code.

State the line numbers that contain the errors and describe how to correct each error.

Error 1 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

(b) State the purpose of this program.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2018 0478/23/O/N/18


9

5 The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.

Fib 1
Prev2 0
Prev1 1
INPUT Number
IF Number = 0
THEN Fib 0
ENDIF
WHILE Number > 2
Fib Prev2 + Prev1
Prev2 Prev1
Prev1 Fib
Number Number - 1
ENDWHILE
OUTPUT Fib

(a) Complete the trace table for the input data: 7

Fib Prev2 Prev1 Number OUTPUT

[4]

(b) Complete the trace table for the input data: 2

Fib Prev2 Prev1 Number OUTPUT

[2]

© UCLES 2018 0478/23/O/N/18 [Turn over


10

6 An online fruit tree specialist sells fruit trees in various sizes. A database table, TREETAB, shows
the tree type and, for each size, the price and whether they are in stock.

Tree Type Size1 Size1 In Size2 Size2 In Size3 Size3 In


Apple 10.95 Yes 14.95 Yes 29.95 Yes
Apple 12.95 Yes 14.95 Yes 29.95 Yes
Cherry 24.95 No 34.95 No 59.95 Yes
Fig 19.95 Yes 29.95 No 49.95 Yes
Guava 19.95 No 29.95 No 59.95 No
Nectarine 8.50 Yes 11.95 Yes 19.95 Yes
Olive 19.95 No 39.95 Yes 59.95 Yes
Peach 9.25 No 11.95 Yes 19.95 Yes
Pear 10.95 Yes 14.95 Yes 29.95 Yes
Plum 8.95 Yes 11.95 Yes 19.95 Yes
Pomegranate 12.95 No 18.95 Yes 34.95 No
Quince 34.95 Yes 44.95 Yes 84.95 No

(a) State whether any of the fields shown would be suitable as a primary key.

...................................................................................................................................................

Explain your answer .................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the table to show the most appropriate data type for each of the fields based on the
data shown in the table at the start of question 6.

Field Data type


Tree Type
Size3
Size2 In
[3]

© UCLES 2018 0478/23/O/N/18


11

(c) Show the output that would be given by this query-by-example.

Field: Tree Type Size1 Size1 In

Table: TREETAB TREETAB TREETAB

Sort: Descending

Show:   

Criteria: <10.00

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(d) Using the following query-by-example grid, write a query to identify all types of the fruit trees
that are out of stock for all three sizes. Make sure the type of the tree and the various ‘in
stock’ fields are shown. The trees should be listed in alphabetical order by type.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

© UCLES 2018 0478/23/O/N/18


7

Section B

2 (a) Write an algorithm, using pseudocode, to input three different numbers, multiply the two
larger numbers together and output the result. Use the variables: Number1, Number2 and
Number3 for your numbers and Answer for your result.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.

Test data set 1 ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Test data set 2 ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2018 2210/22/O/N/18 [Turn over


8

3 Four programming concepts and four descriptions are shown.


Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description


A subroutine that does not
Library routine
have to return a value.

Structure A standard subroutine that is


diagram available for immediate use.

A subroutine that always


Procedure
returns a value.

An overview of a program or
Function
subroutine.
[3]

4 A programmer wants to test that the readings from 2000 electricity meters are greater than 400
units and less than 900 units. The programmer uses selection and repetition statements as part of
the program.
Explain, using programming statements, how selection and repetition could be used in this
program.

Selection ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Repetition .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2018 2210/22/O/N/18


10

5 The flowchart checks the level of chlorine and the depth of water compared to the height of the
swimming pool. Error messages are output if a problem is found.

START

INPUT Height,
Depth, Chlorine

OK True

OUTPUT
Is Depth > Yes
"Water too
Height/2 ? deep"

No
OUTPUT
Is Depth < Yes "Water too
Height/3 ? shallow"

No
OK False

Yes OUTPUT "Too


Is Chlorine much chlorine
>3 ? add more water"
No

OUTPUT "Too
Yes little chlorine
Is Chlorine
<1 ? add more chlorine"
No

No
Is OK = True ?

Yes

OUTPUT "Pool OK
to use"

END

© UCLES 2018 2210/22/O/N/18


11

(a) Complete the trace tables for each set of input data.

Input data: 6, 2.5, 2

Height Depth Chlorine OK OUTPUT

Input data: 4, 3, 1.5

Height Depth Chlorine OK OUTPUT

Input data: 6, 3.5, 4

Height Depth Chlorine OK OUTPUT

[6]

(b) Identify a problem with the algorithm that the flowchart represents.

...................................................................................................................................................

.............................................................................................................................................. [1]

© UCLES 2018 2210/22/O/N/18 [Turn over


12

6 A database table, PORTRAIT, is used to keep a record of the portraits available from a photographic
studio. Each portrait has a unique reference number PICnnn, where n is a single digit, for example
PIC123. The studio keeps a record of the size (for example 20 × 15), the type (black and white or
colour), and the price in dollars.

(a) Complete the table to show the most appropriate data type for each of the fields.

Field Data type

Reference Number

Size

Type

Price in $
[4]

(b) The results from the query-by-example grid should show the reference number, price, type
and size of all portraits under $50. Identify the three errors in the query-by-example grid.

Field: Reference No Price in $ Type Size

Table: PORTRAIT PORTRAIT PORTRAIT PORTRAIT

Sort:

Show:   
Criteria: >50.00

or:

Error 1 .......................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................
[3]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2018 2210/22/O/N/18


7

Section B

2 Describe, giving an example for each, the following data types used in programming.

Integer

Description ........................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

String

Description ........................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................
[4]

3 Give an example of a pseudocode statement or statements to perform each of the following


functions.

A condition controlled loop ...............................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

A conditional statement ....................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Totalling ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2018 2210/23/O/N/18 [Turn over


8

4 This is a section of program code.

1 Total = 100.00
2
PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4 PRINT ′Enter a height in metres′
5 INPUT Height
6 Total = Total + Height
7 PRINT Total / 30
8 Count = Count + 1
9 NEXT Count

(a) There are three errors in this code.

State the line numbers that contain the errors and describe how to correct each error.

Error 1 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

(b) State the purpose of this program.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2018 2210/23/O/N/18


9

5 The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.

Fib 1
Prev2 0
Prev1 1
INPUT Number
IF Number = 0
THEN Fib 0
ENDIF
WHILE Number > 2
Fib Prev2 + Prev1
Prev2 Prev1
Prev1 Fib
Number Number - 1
ENDWHILE
OUTPUT Fib

(a) Complete the trace table for the input data: 7

Fib Prev2 Prev1 Number OUTPUT

[4]

(b) Complete the trace table for the input data: 2

Fib Prev2 Prev1 Number OUTPUT

[2]

© UCLES 2018 2210/23/O/N/18 [Turn over


10

6 An online fruit tree specialist sells fruit trees in various sizes. A database table, TREETAB, shows
the tree type and, for each size, the price and whether they are in stock.

Tree Type Size1 Size1 In Size2 Size2 In Size3 Size3 In


Apple 10.95 Yes 14.95 Yes 29.95 Yes
Apple 12.95 Yes 14.95 Yes 29.95 Yes
Cherry 24.95 No 34.95 No 59.95 Yes
Fig 19.95 Yes 29.95 No 49.95 Yes
Guava 19.95 No 29.95 No 59.95 No
Nectarine 8.50 Yes 11.95 Yes 19.95 Yes
Olive 19.95 No 39.95 Yes 59.95 Yes
Peach 9.25 No 11.95 Yes 19.95 Yes
Pear 10.95 Yes 14.95 Yes 29.95 Yes
Plum 8.95 Yes 11.95 Yes 19.95 Yes
Pomegranate 12.95 No 18.95 Yes 34.95 No
Quince 34.95 Yes 44.95 Yes 84.95 No

(a) State whether any of the fields shown would be suitable as a primary key.

...................................................................................................................................................

Explain your answer .................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the table to show the most appropriate data type for each of the fields based on the
data shown in the table at the start of question 6.

Field Data type


Tree Type
Size3
Size2 In
[3]

© UCLES 2018 2210/23/O/N/18


11

(c) Show the output that would be given by this query-by-example.

Field: Tree Type Size1 Size1 In

Table: TREETAB TREETAB TREETAB

Sort: Descending

Show:   

Criteria: <10.00

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(d) Using the following query-by-example grid, write a query to identify all types of the fruit trees
that are out of stock for all three sizes. Make sure the type of the tree and the various ‘in
stock’ fields are shown. The trees should be listed in alphabetical order by type.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

© UCLES 2018 2210/23/O/N/18

You might also like