O'Level Mock Workshop Paper-2
O'Level Mock Workshop Paper-2
Paper - 2
SIR AAQIB KHAN - AKI
N
Paper 2 Algorithms, Programming and Logic
1 hour 45 minutes
A
You must answer on the question paper.
INSTRUCTIONS
● Answer all questions.
H
K
● Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
IB
INFORMATION
Q
(a)
Draw a line to link each pseudocode description to the most appropriate pseudocode
statement.
FOR…TO…NEXT
N
IF…THEN…ELSE…ENDIF
A
WHILE…DO…ENDWHILE
H CASE…OF…OTHERWISE…ENDCASE
K
a conditional statement with
different outcomes for true and false
REPEAT…UNTIL
IB
[4]
Q
(b) Using a single loop, write an algorithm in pseudocode to output 50 names that have been
stored in the array, Name[]
....................................................................................................................................................
A
....................................................................................................................................................
....................................................................................................................................................
A
....................................................................................................................................................
....................................................................................................................................................
................................................................................................................................................[3]
_____________________________________________________________________
PAGE | 1 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
2 Describe the purpose of validation and verification checks during data entry.
Validation check.................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
Verification check...............................................................................................................................
N
...........................................................................................................................................................
...........................................................................................................................................................
A
...........................................................................................................................................................
[4]
H
K
IB
Q
A
A
_____________________________________________________________________
PAGE | 2 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
3 Tick () one box to show the named section of a program that performs a specific task.
A file
B function
C parameter
D process
[1]
N
4 A satellite navigation system is an example of a computer system that is made up of sub-systems.
A
Part of a satellite navigation system:
• allows the user to enter details for a new destination or select a previously saved destination
• displays directions in the form of a visual map or as a list.
H
Draw a structure diagram for this part of the satellite navigation system.
K
IB
Q
A
[4]
A
_____________________________________________________________________
PAGE | 3 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
5 An algorithm has been written in pseudocode to input some numbers. It only outputs any numbers
that are greater than or equal to 100. The number 999 is not output and stops the algorithm.
INPUT Number
WHILE Numbers <> 999 DO
IF Number > 100
THEN
OUTPUT Number
ENDIF
ENDWHILE
OUTPUT Number
(a)
Identify the four errors in the pseudocode and suggest corrections.
N
Error 1 ........................................................................................................................................
Correction ..................................................................................................................................
A
....................................................................................................................................................
Error 2 ........................................................................................................................................
H
Correction ..................................................................................................................................
K
....................................................................................................................................................
Error 3 ........................................................................................................................................
Correction ..................................................................................................................................
IB
....................................................................................................................................................
Error 4 ........................................................................................................................................
Q
Correction ..................................................................................................................................
....................................................................................................................................................
A
[4]
(b) Write a pseudocode statement to change the corrected algorithm to output all numbers
A
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
............................................................................................................................................... [2]
_____________________________________________________________________
PAGE | 4 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
(a)
Draw a logic circuit for this logic expression.
N
A
B X
C
H
K
[4]
IB
(b)
Complete the truth table from the given logic expression.
Working space
A B C X
Q
0 0 0
0 0 1
A
0 1 0
0 1 1
1 0 0
A
1 0 1
1 1 0
1 1 1
[4]
_____________________________________________________________________
PAGE | 5 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
START
Flag 0
Count 1
N
IS Name[Count] Yes
> Name[Count + 1]? Temp Name[Count]
A
No Name[Count] Name[Count + 1]
HName[Count + 1] Temp
K
Flag 1
Count Count + 1
IB
Q
No IS Count
=4?
A
Yes
A
No IS Flag
=0?
Yes
STOP
_____________________________________________________________________
PAGE | 6 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
The array Name[1:4] used in the flowchart contains the following data:
(a)
Complete the trace table using the data given in the array.
N
A
H
K
IB
Q
[5]
A
(b)
Describe what the algorithm represented by the flowchart is doing.
A
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
............................................................................................................................................... [2]
_____________________________________________________________________
PAGE | 7 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
8 A programmer has written an algorithm to check that prices are less than $10.00
10.00 .................................................................................................................................................
...........................................................................................................................................................
9.99 ...................................................................................................................................................
N
...........................................................................................................................................................
ten .....................................................................................................................................................
A
...........................................................................................................................................................
[3]
H
K
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
IB
...........................................................................................................................................................
...........................................................................................................................................................
Q
...................................................................................................................................................... [3]
A
ENDFUNCTION
Tick () one box which accurately describes the use of the variable Inches
A answer
B call
C parameter
D response
[1]
_____________________________________________________________________
PAGE | 8 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
N
18m08 Venice Beach Action History No Yes No
18m12 Fast Five Action Thriller No Yes No
18m15 King Kong Adventure Fantasy No Yes No
A
18m16 Transformers: The Last Knight Action Sci-Fi Yes Yes Yes
18m17 The Dark Tower Fantasy Sci-Fi Yes Yes No
18m19
18m21
Beauty and the Beast
The Mummy
Fantasy
Action
H
Romance
Fantasy
Yes
No
Yes
No
Yes
Yes
K
18m22 Star Wars: Episode VIII Sci-Fi Action Yes No Yes
18m23 Guardians of the Galaxy Action Sci-Fi Yes Yes Yes
18m26 Thor Action Sci-Fi No Yes Yes
IB
(a)
State the number of records in the database table.
............................................................................................................................................... [1]
A
(b) (i) Give the name of the field that would be used for the primary key.
....................................................................................................................................... [1]
A
(ii) State the reason for choosing this field for the primary key.
............................................................................................................................................
....................................................................................................................................... [1]
_____________________________________________________________________
PAGE | 9 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
(c)
Complete the table to identify the most appropriate data type for each field based on the data
shown in the database table, 2018MOV.
CatNo
Title
N
Genre1
A
Streaming
[2]
H
K
(d)
Complete the structured query language (SQL) to return the category number and title for all
Comedy movies.
.................................................. 2018MOV
_____________________________________________________________________
PAGE | 10 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
• X stores a string
• Y stores a position in the string (e.g. 2)
• Z stores the number of characters in the string.
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
N
....................................................................................................................................................
....................................................................................................................................................
A
............................................................................................................................................... [3]
H
The function Length(X) finds the length of a string X.
(b)
• extract the word fun from the string and output it.
....................................................................................................................................................
....................................................................................................................................................
Q
....................................................................................................................................................
A
....................................................................................................................................................
....................................................................................................................................................
A
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
............................................................................................................................................... [6]
_____________________________________________________________________
PAGE | 11 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
13 The 1D array StudentName[] contains the names of students in a class. The 2D array
StudentMark[] contains the mark for each subject, for each student. The position of
each student’s data in the two arrays is the same, for example, the student in position 10 in
StudentName[] and StudentMark[] is the same.
The variable ClassSize contains the number of students in the class. The variable SubjectNo
contains the number of subjects studied. All students study the same number of subjects.
The arrays and variables have already been set up and the data stored.
N
greater than or equal to 55 and less than 70 merit
greater than or equal to 40 and less than 55 pass
A
less than 40 fail
H
• calculates the average mark for each student for all their subjects, rounded to the nearest
whole number
K
• outputs for each student:
– name
– combined total mark
– average mark
– grade awarded
IB
• calculates, stores and outputs the number of distinctions, merits, passes and fails for the
whole class.
You must use pseudocode or program code and add comments to explain how your code works.
Q
...........................................................................................................................................................
A
...........................................................................................................................................................
A
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
_____________________________________________________________________
PAGE | 12 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
N
...........................................................................................................................................................
...........................................................................................................................................................
A
...........................................................................................................................................................
H
...........................................................................................................................................................
...........................................................................................................................................................
K
...........................................................................................................................................................
...........................................................................................................................................................
IB
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
Q
...........................................................................................................................................................
A
...........................................................................................................................................................
...........................................................................................................................................................
A
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
_____________________________________________________________________
PAGE | 13 Compiled by Sir Aaqib Khan - AKI
O - Level - Computer Science - Paper - 2 Workshop Exam By: Aaqib Khan - AKI
_____________________________________________________________________
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
N
...........................................................................................................................................................
...........................................................................................................................................................
A
...........................................................................................................................................................
H
...........................................................................................................................................................
...........................................................................................................................................................
K
...........................................................................................................................................................
...........................................................................................................................................................
IB
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
Q
...........................................................................................................................................................
A
...........................................................................................................................................................
...........................................................................................................................................................
A
...........................................................................................................................................................
.................................................................................................................................................... [15]
_____________________________________________________________________
PAGE | 14 Compiled by Sir Aaqib Khan - AKI