A Level Paper 2 Mock
A Level Paper 2 Mock
MOCK EXAMINATION-II
A Level
COMPUTER SCIENCE
Paper 2 Fundamental Problem-solving and Programming Skills
2 hours
INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen.
● 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.
● You may use an HB pencil for any diagrams, graphs or rough working.
● 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.
● The insert contains all the resources referred to in the questions.
[Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
(a) Part of the program requires four variables. The following table describes the use of each
variable.
Complete the table by adding the most appropriate data type for each variable.
[4]
(b) The designer considers the use of a development life cycle to split the development of the
website into several stages.
(i) State one benefit of a development life cycle when developing the website.
...........................................................................................................................................
. .................................................................................................................................. [1]
State one document that may be produced from the analysis stage of the website project.
...........................................................................................................................................
. .................................................................................................................................. [1]
3
(c) The program will be developed using the Rapid Application Development (RAD) life cycle.
...........................................................................................................................................
. .................................................................................................................................. [1]
(ii) Give two benefits and one drawback of its use compared to the waterfall life cycle.
Benefit 1 ............................................................................................................................
...........................................................................................................................................
Benefit 2 ............................................................................................................................
...........................................................................................................................................
Drawback ..........................................................................................................................
...........................................................................................................................................
[3]
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
[2]
4
2 A program is being designed for a smartphone to allow users to send money to the charity of their
choice.
Identify three program modules that could be used in the design and describe their use.
Module 1 ..........................................................................................................................................
Use ...................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Module 2 ..........................................................................................................................................
Use ...................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Module 3 ..........................................................................................................................................
Use ...................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[3]
5
Describe the algorithm needed. Do not include pseudocode statements in your answer.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
. ................................................................................................................................................. [5]
6
State the one additional piece of information required before the array can be declared.
...................................................................................................................................................
. .......................................................................................................................................... [1]
(b) A programmer decides to implement a queue Abstract Data Type (ADT) in order to store
characters received from the keyboard. The queue will need to store at least 10 characters
and will be implemented using an array.
(i) Describe two operations that are typically required when implementing a queue.
State the check that must be carried out before each operation can be completed.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Check 1 .............................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
Check 2 .............................................................................................................................
...........................................................................................................................................
[4]
(ii) Describe the declaration and initialisation of the variables and data structures used to
implement the queue.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
. .................................................................................................................................. [5]
7
<StockID><Description><Cost>
Item Length
StockID 5
Description 32
Cost the remainder of the string
A procedure Unpack() takes four parameters of type string. One parameter is the original
text string. The other three parameters are used to represent the three data items shown in
the table and are assigned values within the procedure. These values will be used by the
calling program after the procedure ends.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
. .................................................................................................................................. [6]
(ii) Explain the term procedure interface with reference to procedure Unpack().
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
. .................................................................................................................................. [2]
8
(b) The design changes and a record structure is defined to store the three data items.
TYPE StockItem
DECLARE StockID : STRING
DECLARE Description : STRING
DECLARE Cost : REAL
ENDTYPE
Write the pseudocode statement to assign the value 12.99 to the Cost field of
LineData.
. .................................................................................................................................. [1]
(ii) Procedure Unpack() is modified and converted to a function which takes the original
text string as the only parameter.
Explain the other changes that need to be made to convert the procedure into a function.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
. .................................................................................................................................. [2]
9
(c) Unpack() is part of a program made up of several modules. During the design stage, it is
important to follow good programming practice. One example of good practice is the use of
meaningful identifier names.
Give the reason why this is good practice. Give two other examples of good practice.
Reason .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Example 1 .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Example 2 .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(d) The program that includes Unpack() is tested using the walkthrough method.
Describe this method and explain how it can be used to identify an error.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
. .......................................................................................................................................... [3]
10
6 Components are weighed during manufacture. Weights are measured to the nearest whole gram.
Components that weigh at least 3 grams more than the maximum weight, or at least 3 grams less
than the minimum weight, are rejected.
A component is rechecked if it weighs within 2 grams of either the maximum or minimum weight.
Outcome Weight
Reject
Max + 2
Recheck Max Maximum weight
Max – 2
Accept
Min + 2
Recheck Min Minimum weight
Min – 2
Reject
A function Status() will be called with three parameters. These are integers representing the
weight of an individual component together with the minimum and maximum weights.
(a) Complete the following test plan for five tests that could be performed on function Status().
The tests should address all possible outcomes.
5
11 [5]
12
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
. .......................................................................................................................................... [6]
13
Two global 1D arrays are used to store the syntax error data. Both arrays contain 500 elements.
• Array ErrCode contains integer values that represent an error number in the range 1 to 800.
• Array ErrText contains string values that represent an error description.
...
Note:
• There are less than 500 error codes so corresponding elements in both arrays may be unused.
Unused elements in ErrCode have the value 999. These will occur at the end of the array.
The value of unused elements in ErrText is undefined.
• Values in the ErrCode array are stored in ascending order but not all values may be present.
For example, there may be no error code 31.
• Some error numbers are undefined. In these instances, the ErrCode array will contain a valid
error number but the corresponding ErrText element will contain an empty string.
Module Description
• Prompts for input of two error numbers
• Outputs a list of error numbers between the two numbers input
(inclusive) together with the corresponding error description
• Outputs a warning message when the error description is
missing as for error number 50 in the example
• Outputs a suitable header and a final count of error numbers
found
OutputRange()
Output based on the example array data above:
(a) Write pseudocode for module OutputRange(). Assume that the two numbers input
represent a valid error number range.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
15
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
. .......................................................................................................................................... [8]
Module Description
SortArrays() • Sorts the arrays into ascending order of ErrCode
• Takes two parameters:
• an error number as an integer
• an error description as a string
• Writes the error number and error description to the first
AddError() unused element of the two arrays. Ensures the ErrCode
array is still in ascending order
• Returns the number of unused elements after the new error
number has been added
• Returns −1 if the new error number could not be added
Write pseudocode for the module AddError(). Assume that the error code is not
already in the ErrCode array.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
. .................................................................................................................................. [6]
(ii) A new Module RemoveError() will remove a given error number from the array.
Describe the algorithm that would be required. Do not include pseudocode statements in
your answer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
. .................................................................................................................................. [3]