You are on page 1of 10

318489_Practice_Paper_2A_152-162.

indd Page 152 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms,


programming and logic
Time allowed: 2 hours and 15 minutes
Maximum number of marks: 100
Answer all questions
1 In this question you will be given a statement followed by four possible answers.
Select which of the four answers you think is correct and tick (✔) the box next to your answer.
a What is the symbol for NAND?

b The description of the analysis stage of the program development life cycle.
investigating to provide the specification of what a program is required to do
testing of the program to make sure that it works under all conditions
writing of the program or suite of programs
using the program specification to show to how the program should be developed

c Which statement is used for selection?


NEXT
PROCEDURE
DECLARE
CASE

d The description of a database table


a collection of fields about the same item
a collection of related records
a field that uniquely identifies a record
a single piece of data
 [4]
2 a i) Describe what is meant by a standard method of solution.
. .................................................................................................................................................................
It is illegal to photocopy this page

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

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

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

152 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
318489_Practice_Paper_2A_152-162.indd Page 153 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

ii) Counting is a standard method of solution.


Give three other examples of standard methods of solution.
1  
.............................................................................................................................................................

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

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

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

3  
.............................................................................................................................................................

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

 [3]
b Describe, using an example, the use of counting as a standard method of solution.
........................................................................................................................................................................

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

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

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

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

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

 [3]
3 The table below shows ticked (✔) boxes relating to validation and verification checks.
The following five descriptions have been missed out of the table:
● data must be eight characters long
● data must be entered twice and match
● data is displayed on the screen to be confirmed
● data must have a value between 8 and 12
● data must only contain numbers
Write each description in the correct row of the table and name each check.
Method used
Description Validation Verification Name of check




It is illegal to photocopy this page

 [5]

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 153
318489_Practice_Paper_2A_152-162.indd Page 154 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

4 a i) Explain why test data is required.


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

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

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

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

 [2]
ii) State three types of test data.
1  
.............................................................................................................................................................

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

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

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

3  
.............................................................................................................................................................

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

 [3]
b A program accepts values that are whole numbers between 30 and 40 inclusive.
Give examples of test data that are required.
Explain, including the expected outcome, why each piece of test data is needed.
........................................................................................................................................................................

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

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

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

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

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

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

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

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

........................................................................................................................................................................
It is illegal to photocopy this page

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

 [6]

154 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
318489_Practice_Paper_2A_152-162.indd Page 155 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

5 This algorithm is written in pseudocode.

01 REPEAT
02 OUTPUT "Please enter your password"
03 INPUT Password
04 IF Length(Password) < 10
05 THEN
06 OUTPUT "Reject too short"
07 ELSE
08 Symbol ← FALSE
09 PasswordUp ← UCASE(Password)
10 FOR Counter ← 1 TO Length(Password)
11 IF SUBSTRING(PasswordUp, Counter, 1) > 90 OR
SUBSTRING(PasswordUp, Counter, 1) < 65
12 THEN
13 Symbol ← TRUE
14 ENDIF
15 NEXT Counter
16 IF Symbol
17 THEN
18 OUTPUT "Accept"
19 ELSE
20 OUTPUT "Reject no symbol"
21 ENDIF
22 ENDIF
23 UNTIL Symbol AND Length(Password) >= 10

a i) State the purpose of the algorithm.


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

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

 [1]
ii) Identify the line number(s) for these types of statement.
Assignment
It is illegal to photocopy this page

. .................................................................................................................................................................
Selection
. .................................................................................................................................................................
Iteration
. .................................................................................................................................................................

 [2]

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 155
318489_Practice_Paper_2A_152-162.indd Page 156 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

b i) Complete the trace table for the algorithm using this data MyPassword!
Password PasswordUp Symbol Counter OUTPUT

 [4]
ii) Complete the trace table for MyWord!
Password PasswordUp Symbol Counter OUTPUT

 [2]
6 a i) Describe the difference between variables and constants in programming.
. .................................................................................................................................................................

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

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

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

 [2]
ii) Give three basic data types that are used in programming.
1  
.............................................................................................................................................................
It is illegal to photocopy this page

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

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

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

3  
.............................................................................................................................................................

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

 [3]

156 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
318489_Practice_Paper_2A_152-162.indd Page 157 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

b Write pseudocode statements to declare a variable to store the number of children in a class
and a constant with the value 30 that is the maximum number of children that could be
included in a class.
........................................................................................................................................................................

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

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

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

 [3]
7 Describe, with the use of examples, the different types of operators that can be used when
programming.
.............................................................................................................................................................................

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

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

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

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

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

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

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

 [4]
8 In the following diagram, six descriptions are shown on the left and eight library routines
are shown on the right.
By drawing lines, connect each description to the correct library routine.
DIV
Returns the remainder of a division.
LCASE
Returns a random number.
LENGTH
Returns the number of characters.
MOD
Returns a string where all letters are lower case. RANDOM

Returns a string where all letters are upper case. ROUND

Returns the quotient of a division. SUBSTRING


It is illegal to photocopy this page

UCASE

 [6]
9 a i) Explain what is meant by the term array.
. .................................................................................................................................................................

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

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

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

 [2]

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 157
318489_Practice_Paper_2A_152-162.indd Page 158 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

ii) Describe, using an example, how a variable is used as an array index.


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

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

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

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

 [2]
iii) Describe the difference between 1D and 2D arrays.
. .................................................................................................................................................................

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

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

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

 [2]
b Write pseudocode statements to declare and populate a 2D array with 20 rows of four zeros. Use
iteration to populate the array.
........................................................................................................................................................................

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

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

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

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

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

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

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

 [4]
c Give one advantage and one disadvantage of using arrays.
Advantage:
........................................................................................................................................................................

........................................................................................................................................................................
Disadvantage:
It is illegal to photocopy this page

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

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

 [2]

158 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
318489_Practice_Paper_2A_152-162.indd Page 159 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

10 Read this section of pseudocode that inputs fifty (50) negative numbers and then outputs
the largest negative number input.

01 Large ← 9999
02 Counter ← 50
03 WHILE Counter > 50 DO
04 REPEAT
05 INPUT NegNum
06 UNTIL NegNum > 0
07 IF NegNum < Large THEN Large ← NegNum
08 Counter = Counter - 1
09 ENDWHILE
10 OUTPUT "Largest number is ", Large

There are five errors in this code.


Locate these errors and suggest a corrected piece of code for each error.
1  
.......................................................................................................................................................................

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

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

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

3  
.......................................................................................................................................................................

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

4  
.......................................................................................................................................................................

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

5  
.......................................................................................................................................................................

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

 [5]
11 A database of plants for sale, PlantSale, is to be set up with the following fields:
● PlantName – for example Begonia
● PlantPrice – for example $10.00
● PlantID – for example PL579
It is illegal to photocopy this page

● Position – for example, shade or sun


● PlantHeight – for example, 1.5
● StockAvailable – for example, 25

a State, with a reason, a suitable data type for these fields:


PlantPrice
........................................................................................................................................................................

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

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 159
318489_Practice_Paper_2A_152-162.indd Page 160 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

PlantHeight
........................................................................................................................................................................

........................................................................................................................................................................
Position
........................................................................................................................................................................

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

 [3]
b State which field you would choose for the primary key and explain why it is appropriate.
........................................................................................................................................................................

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

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

 [2]
c Complete this SQL script to display the names, prices and number in stock of all plants taller
than 1.8 metres.
SELECT PlantName, Price, ............................................................................................................

FROM .............................................................................................................................................................

WHERE .............................................................................................................................................. > 1.8;


 [3]
12 Consider this logic expression.
X = (A AND B) XOR (NOT B AND NOT C)
a Complete the truth table for this logic expression.
Inputs Working space Output
A B C X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
It is illegal to photocopy this page

1 1 1

 [4]

160 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
318489_Practice_Paper_2A_152-162.indd Page 161 12/07/22 1:20 PM F-0250 /145/HO02580/work/indd

Practice Paper 2A Algorithms, programming and logic

b Draw a logic circuit for the un-simplified logic expression. Each logic gate must have a maximum
of two inputs.
 [4]

B X

13 The one-dimensional array BabyName[] contains the names of the babies in a nursery.
Another one-dimensional array ParentPhone[] contains the phone numbers for the parents
of the baby.
A final one-dimensional array BabyAge[] contains the baby’s age in months.
The position of each baby’s data in the three arrays is the same; for example, the baby in
position 3 in BabyName[], ParentPhone and BabyAge[] is the same.
Write and test a program that meets the following requirements:
● uses procedures to display these lists:
– parent phone numbers and baby names in alphabetic order of baby name
– baby names for babies aged under three months
● uses a procedure to display all the details for a baby, with the name used as a parameter
● uses a procedure to update the details for a baby, with the name used as a parameter.
You must use pseudocode or program code with local and global variables and add comments to
explain how your code works. All inputs and outputs must contain suitable messages.
 [12]

It is illegal to photocopy this page

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 161

You might also like