Algorithm design and problem-solving – O Level Computer Science (2210)
137 questions · page 9 of 10
Question text
4
IF … THEN … ELSE … ENDIF is one type of conditional statement used when writing
pseudocode.
Identify and describe another type of conditional statement that you could use when writing
pseudocode. Give a reason why you would use this type of conditional statement.
Conditional statement …
…
…
…
Description …
…
…
…
Reason …
…
[4]
Question text
5
(a) This flowchart checks a batch of 10 rice sacks for weight. Sacks should weigh 50 kilograms
each. Sacks weighing over 50.5 kilograms or less than 49.5 kilograms are rejected. The
number of sacks accepted and the number of sacks rejected is output.
START
Accept
0
Reject
0
Count
0
Yes
Is Count
= 10?
OUTPUT
Accept,
Accept
Accept + 1
No
Reject
Count
Count + 1
END
INPUT
Sack
Is Sack
Yes
Reject
Reject + 1
< 49.5?
No
Is Sack
> 50.5?
No
Yes
Complete the trace table for the input data:
50.4, 50.3, 49.1, 50.3, 50.0, 49.5, 50.2, 50.3, 50.5, 50.6
Accept
Reject
Count
Sack
OUTPUT
[5]
(b) The size of the batch has increased to 50 sacks. It has been decided to only reject sacks that
are underweight.
State the changes that need to be made to the flowchart.
…
…
…
… [2]
Question text
3
(a) Explain the difference between a validation check and a verification check.
…
…
… [2]
(b) Describe, using an example, how data could be verified on data entry.
…
…
… [2]
(c) Explain what is meant by the term library routine.
…
…
… [2]
Question text
5
The flowchart below represents a program routine.
START
Flag
0
Count
1
Is Name[Count]
Yes
Temp
Name[Count]
> Name[Count + 1]?
No
Name[Count]
Name[Count + 1]
Name[Count + 1]
Temp
Flag
1
Count
Count + 1
No
Is Count
= 4?
Yes
No
Is Flag
= 0?
Yes
END
(a) The array used in the flowchart contains the following data:
Name[1]
Name[2]
Name[3]
Name[4]
Jamal
Amir
Eve
Tara
Complete the trace table using the data given in the array.
Flag
Count
Name[1]
Name[2]
Name[3]
Name[4]
Temp
Jamal
Amir
Eve
Tara
[5]
(b) Describe what the algorithm represented by the flowchart is doing.
…
… [2]
Question 6 begins 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
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
Question text
3
A satellite navigation system works using destination details entered by the user, either a new
destination or chosen from previously saved destinations. The satellite navigation system will then
output directions to the destination in the form of either a visual map or a list of directions.
A satellite navigation system is an example of a computer system that is made up of sub-systems.
This structure diagram shows some of its sub-systems.
Complete the diagram by filling in the empty boxes.
Satellite navigation system
Input destination
Map
List
[2]
Question text
4
For each of the four statements in the table, place a tick in the correct column to show whether it
is an example of validation or verification.
Statements
Validation
Verification
To automatically check the accuracy of a bar code
To check if the data input is sensible
To check if the data input matches the data that has been
supplied
To automatically check that all required data fields have been
completed
[4]
Question text
5
(a) Describe the purpose of each statement in this algorithm.
1 TO 300
FOR I
INPUT Name[I]
NEXT I
…
…
…
…
… [2]
(b) Identify, using pseudocode, another loop structure that the algorithm in part (a) could have
used.
…
… [1]
(c) Write an algorithm, using pseudocode, to input a number between 0 and 100 inclusive. The
algorithm should prompt for the input and output an error message if the number is outside
this range.
…
…
…
…
…
…
…
…
…
… [3]
Question text
6
This flowchart inputs a range of temperatures in degrees Fahrenheit.
As each temperature is input, it is compared with the previous highest temperature. If it is higher
than the current highest, it replaces the previous highest temperature and then it is converted to
degrees Celsius.
For ease of calculation, the final step of the Fahrenheit to Celsius conversion has been
approximated as division by 2.
When –1 is entered, the input process stops and the highest temperature (in both Fahrenheit and
Celsius) is output.
START
HighF
-100
HighC
-100
INPUT TempF
No
No
Is TempF
Is TempF
> HighF?
= -1?
Yes
Yes
HighF
TempF
HighC
(TempF-32)/2
OUTPUT 'The highest temperature is, ',
HighF, ' Fahrenheit, ',
HighC, ' Celsius.'
END
Complete the trace table for the input data:
68, 46, 50, 86, 65, 50, 40, 30, –1
HighF
HighC
TempF
OUTPUT
[5]
Question text
2
(a) Write an algorithm to input three different numbers, and then output the largest number. Use
either pseudocode or a flowchart.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [4]
(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]
Question text
3
This flowchart inputs the weight of items in kilograms to be loaded on a trailer. Any item over
25 kilograms is rejected. The trailer can take up to 100 kilograms.
START
TotalWeight
0
Reject
0
INPUT Weight
Yes
Is Weight
Reject
Reject + 1
˃ 25?
No
TotalWeight
TotalWeight + Weight
Is
No
TotalWeight
˃ 100?
Yes
TotalWeight
TotalWeight – Weight
OUTPUT 'Weight of items ' ’
TotalWeight, ' Number of
items rejected ',Reject
END
Complete the trace table for the input data:
13, 17, 26, 25, 5, 10, 15, 35, 20, 15
Weight
Reject
TotalWeight
OUTPUT
[5]
Question text
4
An algorithm has been written in pseudocode to input 100 numbers and print out the sum.
A REPEAT … UNTIL loop has been used.
Count ← 0
Sum ← 0
REPEAT
INPUT Number
Sum ← Sum + Number
Count ← Count + 1
UNTIL Count > 100
PRINT Sum
(a) Find the error in the pseudocode and suggest a correction.
Error …
Correction …
…
[2]
(b) Rewrite the correct algorithm using a more suitable loop structure.
…
…
…
…
…
…
… [3]
Question text
The flowchart below inputs an integer. The predefined function DIV gives the value of the division,
3
for example Z ← 11 DIV 3 gives the value Z = 3. The predefined function MOD gives the value
of the remainder, for example Z ← 11 MOD 3 gives the value Z = 2.
67$57
,1387 ;
1R
Is X >
"
<HV
$
; ',9
287387 ;
%
; 02'
(1'
287387 %
;
$
Complete a trace table for each of the two input values 33 and 75.
Trace table for input value 33
X
A
B
OUTPUT
Trace table for input value 75
X
A
B
OUTPUT
[4]
Question text
3
The flowchart below inputs the price of an item under $10. The change from a $10 note is output.
Any amount less than 5 cents is rounded up to 5 cents.
The predefined function INT rounds a number down to the nearest whole number; for example
Z ← INT(5.7) gives the value Z = 5
START
INPUT Price
Change
10 – Price
Is
Yes
Change
Dollars
INT(Change)
>= 1?
No
Change
Change – INT(Change)
OUTPUT Dollars,
" dollars"
Is
Yes
Change
Change
Change – 0.5
>= 0.5?
No
OUTPUT "One 50
cent coin"
TenCents
INT(Change * 10 + 0.5)
OUTPUT TenCents,
" ten cent coins"
Is Change*10 –
OUTPUT "One 5
Yes
TenCents
cent coin"
> 0?
No
END
Complete the trace table for the input data: 6.29
Price
Change
Dollars
TenCents
OUTPUT
[5]
Question text
4
Four validation checks and four descriptions are shown below.
Draw a line to link each validation check to the correct description.
Validation check
Description
Numbers between two
Presence check
given values are accepted
Data is of a particular
Range check
specified type
Data contains an exact
Type check
number of characters
Ensures that some data
Length check
have been entered
[3]
Question text
4
The flowchart below inputs the height of children who want to ride on a rollercoaster. Children
under 1.2 metres are rejected. The ride starts when eight children have been accepted.
67$57
5LGHUV
5HMHFW
,1387
+HLJKW
,V
<HV
+HLJKW
5HMHFW 5HMHFW
"
1R
5LGHUV 5LGHUV
287387
<HV
1R
5LGHUV
5eady to go , 5eject
"
(1'
Complete the trace table for the input data:
1.4, 1.3, 1.1, 1.3, 1.0, 1.5, 1.2, 1.3, 1.4, 1.3, 0.9, 1.5, 1.6, 1.0
Riders
Reject
Height
OUTPUT
[4]