0% found this document useful (0 votes)
27 views16 pages

June 2016 QP - Paper 2 OCR Computer Science AS-level

This document is an examination paper for the AS Level Computer Science course, focusing on algorithms and problem solving. It includes various questions related to programming constructs, testing strategies, binary search, and pseudocode, with a total mark of 70. The exam is structured to assess students' understanding of computer science concepts and their application in problem-solving scenarios.

Uploaded by

kodularcoding
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views16 pages

June 2016 QP - Paper 2 OCR Computer Science AS-level

This document is an examination paper for the AS Level Computer Science course, focusing on algorithms and problem solving. It includes various questions related to programming constructs, testing strategies, binary search, and pseudocode, with a total mark of 70. The exam is structured to assess students' understanding of computer science concepts and their application in problem-solving scenarios.

Uploaded by

kodularcoding
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Oxford Cambridge and RSA

AS Level Computer Science


H046/02 Algorithms and problem solving

Tuesday 14 June 2016 – Afternoon


Time allowed: 1 hour 15 minutes
* 6 4 1 1 6 0 5 9 3 9 *

Do not use:
• a calculator

* H 0 4 6 0 2 *

First name

Last name

Centre Candidate
number number

INSTRUCTIONS
• Use black ink.
• Complete the boxes above with your name, centre number and candidate number.
• Answer all the questions.
• Write your answer to each question in the space provided.
• If additional space is required, you should use the lined page(s) at the end of this
booklet. The question number(s) must be clearly shown.
• Do not write in the barcodes.

INFORMATION
• The total mark for this paper is 70.
• The marks for each question are shown in brackets [ ].
• Quality of extended responses will be assessed in questions marked with an
asterisk (*).
• This document consists of 16 pages.

© OCR 2016 [601/5030/0] OCR is an exempt Charity


DC (KN) 130255/4 Turn over
2
1 Programming languages consist of three basic programming constructs. For each construct, state
its name and give a working example.

Construct 1: ......................................................................................................................................

Example: ..........................................................................................................................................

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

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

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

Construct 2: ......................................................................................................................................

Example: ..........................................................................................................................................

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

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

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

Construct 3: ......................................................................................................................................

Example: ..........................................................................................................................................

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

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

..........................................................................................................................................................
[6]

© OCR 2016
3
2* A software company is going to write a policy on its use of variables when writing programs. The
policy will cover the use of local and global variables and variable naming rules and conventions.

Discuss the content of this policy and why it is required. [9]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

© OCR 2016 Turn over


4

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

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

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

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

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

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

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

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

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

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

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

3 (a) A software development company is planning to produce a bespoke monitoring system for a
factory which produces hazardous chemicals. One testing strategy is whitebox testing.

State the name of three other testing strategies that the company could use.

1 ................................................................................................................................................

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

3 ........................................................................................................................................... [3]

© OCR 2016
5
(b) The company decide to use whitebox testing. Justify why whitebox testing is used in this
case.

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

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

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

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

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

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

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

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

.............................................................................................................................................. [3]

(c) A temperature control system monitors and regulates temperature by switching a heater
on or off. The temperature sensor of the system provides a reading accurate to 3 decimal
places (e.g. 87.489). There are two warning lights, amber and red. The system controls the
temperature and warning lights as follows:

• The heater is turned off when the sensor reading is 97.500.


• The heater is turned on when the sensor reading is 95.000.
• The red warning light is on when the sensor reading is 98.100 or above.
• The amber warning light is on when the sensor reading is outside the range 95.000 to
97.500 (inclusive), and the red warning light is not on.

Complete the boundary test table below.

Sensor value Output On/off


94.999 Amber light on
Heater
95.000
Amber light
Heater
97.500
Amber light
97.501 Amber light
Amber light
98.099
Red light
Amber light
98.100
Red light
[5]

© OCR 2016 Turn over


6
4 (a) Describe the steps involved in a binary search to find the value 47 in the list below.

4, 7, 8, 21, 46, 47, 51

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

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

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

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

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

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

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

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

...................................................................................................................................................
[4]

© OCR 2016
7
(b) A programmer has been tasked with writing a function that uses a binary search to return
a Boolean value. The function should return true if the target integer is found in a list of
integers. Using pseudocode, write an algorithm for the function.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...................................................................................................................................................
[8]

© OCR 2016 Turn over


8
(c) The target integer 8 exists in a list of integers 1, 4, 6, 9, 8, 12, 15 but is not found during a
binary search. There are no errors in the code.

(i) Give the reason why the target integer 8 is not found.

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

...................................................................................................................................... [1]

(ii) Identify and describe an alternative search algorithm that could be used.

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

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

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

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

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

...................................................................................................................................... [3]

© OCR 2016
9
(d) A stack, in shared memory, is being used to pass a single variable length ASCII string
between two sub-systems. The string is placed in the stack one character at a time in reverse
order with the last byte holding the number of characters pushed i.e the text “SILVER” would
be held in the stack as:

6 Top
S
I
L
V
E
R

Use pseudocode to write a procedure that will take a text string passed to it and push it to the
stack in the format defined above. You may assume any given input will fit in the stack.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.............................................................................................................................................. [6]
© OCR 2016 Turn over
10
5 A car racing team uses a car simulator to test their drivers in a range of cars on different race
tracks.

(a) The car simulator uses an abstraction of the real car and race track. Identify two ways in
which the simulator could use abstraction.

1 ................................................................................................................................................

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

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

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

(b) Identify three inputs that will be required to configure the initial conditions for running the
simulation.

1 ................................................................................................................................................

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

3 ........................................................................................................................................... [3]

© OCR 2016
11
6 (a) A programmer is going to design a procedure that will prompt for and receive two values,
A and B. The procedure will then compare them. The procedure will also write a suitable
message to a file on disk depending on whether:

• the values are the same


• A is less than B, or
• B is less than A.

Use pseudocode to write the procedure.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.............................................................................................................................................. [5]

© OCR 2016 Turn over


12
(b) The code below uses a procedure:

name = "Sam"
addMessage(name)
print(name)

procedure addMessage(inText:byVal)
inText = "Hello " + inText
endprocedure

Explain why this program outputs Sam rather than Hello Sam.

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

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

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

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

(c) Explain the advantages of writing an application using a modular approach.

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

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

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

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

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

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

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

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

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

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

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

.............................................................................................................................................. [6]

© OCR 2016
13
7 Given the following pseudocode:

d = 5

if ((a > b) OR (b >= c)) then


if ((c < a ) XOR (c < b)) then // Check to see if one or the other
// comparisons are TRUE, but not both
d = 15
else
d = 16
endif
else
d = 14
endif

print(d)

(a) State the value of d if a=42, b=41 and c=42 ..........................

(b) State the value of d if a=42, b=36 and c=4 ..........................

(c) State the value of d if a=42, b=36 and c=36 ..........................

(d) Give one potential value of b if the output value of a=42, c=44
and d=14. ..........................
[4]

END OF QUESTION PAPER

© OCR 2016
14
ADDITIONAL ANSWER SPACE

If additional space is required, you should use the following lined page(s). The question number(s)
must be clearly shown in the margin(s).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

© OCR 2016
15

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

© OCR 2016
16

PLEASE DO NOT WRITE ON THIS PAGE

Oxford Cambridge and RSA


Copyright Information
OCR is committed to seeking permission to reproduce all third-party content that it uses in its assessment materials. OCR has attempted to identify and contact all copyright holders
whose work is used in this paper. To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced in the OCR Copyright
Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download from our public website (www.ocr.org.uk) after the live examination series.
If OCR has unwittingly failed to correctly acknowledge or clear any third-party content in this assessment material, OCR will be happy to correct its mistake at the earliest possible
opportunity.
For queries or further information please contact the Copyright Team, First Floor, 9 Hills Road, Cambridge CB2 1GE.
OCR is part of the Cambridge Assessment Group; Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a
department of the University of Cambridge.

© OCR 2016

You might also like