Computer Science Mock Exam Paper 2
Computer Science Mock Exam Paper 2
¬O. 4mHuOªE^y6W
¬`qR©¥^z}:`hy
¥¥u5uE55EeE UUU
* 2 5 6 1 2 6 5 1 3 6 *
COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic
1 hour 45 minutes
INSTRUCTIONS
● Answer all questions.
● 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.
● Calculators must not be used in this paper.
INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.
2
, ,
A bubble sort.
B counting routine.
C linear search.
D selection search.
[1]
The pseudocode to store a hotel name held in the variable Name to a text file is
3 Four development life cycle stages and five descriptions are shown.
Draw one line from each stage to the most appropriate description.
Not all descriptions will be used.
Stage Description
coding
using structure diagrams, flowcharts and pseudocode to
plan the solution
[4]
* 0000800000003 *
3
, ,
...................................................................................................................................................
............................................................................................................................................. [1]
(i) Identify the validation check used to test whether the value input meets this requirement.
..................................................................................................................................... [1]
(ii) Write the pseudocode for an algorithm to allow a number to be input into an appropriate
variable and check whether the number is an integer. If the number is an integer, it is
accepted. If the number is not an integer, an error message is output. Re-input of the
number is required until a valid number is input.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [5]
* 0000800000004 *
4
, ,
5 A program is written to only accept data that contains more than 9 characters. The program needs
to be tested. The table, when completed, shows appropriate test data that matches the type of test
data and the purpose of the test data.
ABC ......................................................................
......................................................................
Boundary ......................................................................
......................................................................
[6]
6 This pseudocode algorithm is intended to allow 1000 positive integers to be input and stored in
a one-dimensional (1D) array. The integers are added together as they are input and the highest
value is identified. At the end of the algorithm, the highest number, the total and the average of the
numbers are output.
(a) Identify the line numbers of five errors in the pseudocode and suggest a correction for each
error.
Correction .................................................................................................................................
...................................................................................................................................................
* 0000800000005 *
5
, ,
Correction .................................................................................................................................
...................................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
[5]
(b) Write the pseudocode statement to output the average of the numbers, rounded to two
decimal places.
...................................................................................................................................................
............................................................................................................................................. [2]
(c) Explain how you could change the corrected algorithm so that it also finds the smallest
number that was input and outputs its value at the end.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
* 0000800000006 *
6
, ,
START
OUTPUT
"Continue?"
INPUT Answer
No IS Answer = Yes
'Y' ?
INPUT
STOP Value1
INPUT
Operator
Yes IS Operator =
'S' ?
OUTPUT
Value1 – No
Value2
Yes IS Operator = No
'M' ?
OUTPUT OUTPUT
Value1 * Value1 /
Value2 Value2
* 0000800000007 *
7
, ,
[5]
............................................................................................................................................. [1]
(c) There are problems with the given algorithm. If the lower-case letter ‘y’ is entered for Answer,
the algorithm stops and if a lower-case letter is entered for Operator, the algorithm gives an
incorrect output.
(i) Explain how you would change the algorithm to prevent the problems described.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
(ii) Identify one more error related to inputs when the algorithm is run.
...........................................................................................................................................
..................................................................................................................................... [1]
* 0000800000008 *
8
, ,
8 A database table, MajorCity, stores some details about a number of cities from around the
world.
(a) State the number of fields and records in this database table.
Fields ........................................................................................................................................
Records ....................................................................................................................................
[2]
* 0000800000009 *
9
, ,
(b) Identify the field in the database table that is most suitable to be the primary key and give
one reason for your choice.
Reason .....................................................................................................................................
...................................................................................................................................................
[2]
(c) Give the output from the structured query language (SQL) statement:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(d) Complete the SQL statement to list only the code, city, country and continent of all the cities
in the database table that are capital cities.
SELECT ....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
* 0000800000010 *
10
, ,
B Z
[5]
(b) Complete the truth table from the given logic expression.
Working space
A B C Z
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[4]
* 0000800000012 *
12
, ,
10 A sports club uses a six-character alphanumeric membership code to identify each member of the
club.
The one-dimensional (1D) array MemberID[] is used to store the unique membership codes for
club members.
The two-dimensional (2D) array Name[] is used to store the names of the club members. The first
and last name of each member will be stored in separate array elements.
The position of any member’s data is the same in both arrays. For example, the data in index 2 of
MemberID[] belongs to the member in index 2 of Name[]
• Provide a menu that offers the choices: inputting a new member, outputting a list of
membership codes and first and last names, or stopping.
• Input and validate a response to the menu.
• When inputting a new member, input a new membership code and check that it contains six
characters:
○ If the new code is six characters, check it against all the previously stored membership
codes to make sure it is unique.
○ If the code is not unique, a new code must be entered and checked.
○ If the code is unique, it is stored in the first available space in the appropriate array
and the new member is required to enter their first name and last name, which are also
stored in the corresponding location of the appropriate array.
• When outputting a list of membership codes and names, output for each member: their
membership code, first name and last name.
• The program will continue until the stop option on the menu is selected.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays, variables or constants; assume this has already been
done.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
* 0000800000013 *
13
, ,
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
* 0000800000014 *
14
, ,
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
................................................................................................................................................... [15]