Computer Science Unit 2 Past Paper
Computer Science Unit 2 Past Paper
Do not use:
• a calculator
* J 2 7 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, 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 80.
• The marks for each question are shown in brackets [ ].
• This document consists of 16 pages.
No calculator can
be used for this
paper
1 OCR High School uses a computer system to store data about students’ conduct. The system
records good conduct as a positive number and poor conduct as a negative number. A TRUE
or FALSE value is also used to record whether or not a letter has been sent home about each
incident.
Fig. 1
(a)
State the most appropriate data type used to store each of the following items of data.
• StudentName .....................................................................................................................
• Points .................................................................................................................................
• LetterSent ...........................................................................................................................
[3]
(b)
The data shown above in Fig. 1 is stored in a database table called Conduct.
(i)
Write an SQL statement to select the StudentName field for all records that have negative
Points.
. [3]
(ii) State the wildcard that can be used in SQL to show all fields from a table.
. [1]
© OCR 2018
3
(c)
A single record from this database table is read into a program that uses an array with the
identifier studentdata. An example of this array is shown below:
Write an algorithm that will identify whether the data in the studentdata array shows that
a letter has been sent home or not for the student. The algorithm should then output either
“sent” (if a letter has been sent) or “not sent” (if a letter has not been sent).
. [4]
01 for k = 1 to 3
02 for p = 1 to 5
03 print (k + p)
04 next p
05 next k
06 m = 7
07 print m * m
(a) (i) Give the first three numbers that will be printed by this algorithm.
. [1]
(ii) State how many times line 03 will be executed if the algorithm runs through once.
. [1]
(b) Identify two basic programming constructs that have been used in this algorithm.
1 .................................................................................................................................................
2 .................................................................................................................................................
....................................................................................................................................................
[2]
.............................................................................................................................. [2]
(ii) Identify two variables that have been used in the algorithm above.
1.
2 .........................................................................................................................................
[2]
© OCR 2018
5
3 The logic diagram below (Fig. 2) shows a system made up of two connected logic gates.
Fig. 2
(a) (i) Label the names of the two gates on the diagram above. [2]
(ii) Complete the truth table below to show the output from this logic system.
A B Q
0 0
0 1
1 0
1 1
[4]
(b)
Draw the logic diagram represented by Q = A 0 ¬B
[2]
For example, “Poetry from the War”, published in 2012 would be given the code POE12.
(a) (i) Complete the following pseudocode for a function definition that will take in the book title
and year as parameters and return the book code.
03 partb = year.subString(2, 2)
05 endfunction
[3]
. [6]
© OCR 2018
7
(b) Functions and procedures are both examples of sub programs.
(i)
Describe one difference between a function and a procedure.
............................................................................................................................. [2]
. [4]
(i)
Show the steps that a merge sort would take to put the following list of book codes into
ascending alphabetical order (from A to Z).
............................................................................................................................... [4]
. [2]
© OCR 2018
9
5 (a) (i) Convert the denary number 132 into an 8 bit binary number.
. [2]
. [2]
(iii) Show the effect of a binary shift right of two places on the binary number 00110100.
. [1]
(iv) Describe a shift that can be used to double the value of the binary number 00100100.
. [2]
The lower case ASCII code for a character can be found by adding 0100000 to the upper
case version.
R 1010010
r 1110010
A 1000001
E 1000101
Fig. 3
(i)
Complete the table above by filling in the missing ASCII codes. [2]
(ii) Compare the use of ASCII and Extended ASCII to represent characters.
. [2]
© OCR 2018
11
6 An infinite loop is where a section of a program repeats indefinitely.
(a)
For each of the pseudocode algorithms shown below, tick the appropriate box to show
whether they will loop infinitely or not.
(b)
Using pseudocode, write an algorithm that will use a count-controlled loop to print out the
numbers 1 to 10 in ascending order.
. [3]
01 a = input(“Enter an acronym”)
02 if a == “LAN” then
06 ……………………………………………………………………………………………
07 ……………………………………………………………………………………………
08 endif
(a) (i) Complete the code above to print out an “unknown” message if any other acronym is
entered by the user. [2]
. [2]
(b)
Victoria creates her program using an Integrated Development Environment (IDE).
. [4]
© OCR 2018
13
8 OCR town are holding an election with three candidates (A, B and C). An electronic voting booth
will be used to allow people to vote.
. [6]
© OCR 2018
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 2018
15
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
© OCR 2018
16
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������
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 2018