0% found this document useful (0 votes)
366 views20 pages

Question Paper Computational Thinking Algorithms and Programming

Uploaded by

Catalina Par
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
366 views20 pages

Question Paper Computational Thinking Algorithms and Programming

Uploaded by

Catalina Par
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 20

Oxford Cambridge and RSA

Friday 06 November 2020 – Afternoon


GCSE (9–1) Computer Science
J276/02 Computational thinking, algorithms and programming
Time allowed: 1 hour 30 minutes
Do not use:
* 8 2 7 3 6 5 0 3 1 5 *

• a calculator

* J 2 7 6 0 2 *

Please write clearly in black ink. Do not write in the barcodes.

Centre number Candidate number

First name(s) �

Last name �

INSTRUCTIONS
• Use black ink.
• Write your answer to each question in the space provided. If you need extra space use
the lined pages at the end of this booklet. The question numbers must be clearly shown.
• Answer all the questions.

INFORMATION
• The total mark for this paper is 80.
• The marks for each question are shown in brackets [ ].
• This document has 20 pages.

ADVICE
• Read each question carefully before you start your answer.

© OCR 2020 [601/8355/X] OCR is an exempt Charity


DC (DH/FC) 199454/5 Turn over
2
Answer all the questions

1 The following table contains several definitions of terms that are used in Computer Science.

Letter Definition
A Cleaning up data entered by removing non-standard characters
B Hiding or removing irrelevant details from a problem to reduce complexity
C Checking that the user is allowed to access the program
D Breaking a complex problem down into smaller problems
E Repeating elements of a program
F Converting one data type to another, for example converting an integer to a real number

(a) Write the letter of the definition that matches each keyword in each space.

Decomposition ..................

Abstraction ..................

Input sanitisation ..................

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

(b) (i) Write a pseudocode statement to assign the value 7.3 to a variable with the identifier
timer

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

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

(ii) State the most appropriate data type for the variable timer.

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

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

© OCR 2020
3
BLANK PAGE

PLEASE DO NOT WRITE ON THIS PAGE

© OCR 2020 Turn over


4
2 Dru writes the following program using a high-level language.

01 function newscore(a,b)
02 temp = a*b
03 temp = temp + 1
04 return temp
05 endfunction
06 score = 18
07 name = "Dru"
08 print (score)
09 print ("name")
10 print (newscore(score,2))
11 print (score)

(a) The following table contains the program code for each line where this program outputs
values.

State the values output by the program on each of the lines.

Line Program code Value output

08 print (score)

09 print ("name")

10 print (newscore(score,2))

11 print (score)

[4]

© OCR 2020
5
(b) Describe the advantages of writing the program in a high-level language instead of in
assembly language.

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

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

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

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

(c) Describe how a character set is used to represent the string value stored in the variable name

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

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

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

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

© OCR 2020 Turn over


6
BLANK PAGE

PLEASE DO NOT WRITE ON THIS PAGE

© OCR 2020
7
3 A vending machine has the following options available.

Item code Item name Price


A1 Crisps, bacon flavour £0.75
A2 Crisps, salted £0.75
B1 Chocolate bar £0.90
C1 Apple pieces £0.50
C2 Raisins £0.85

Users insert coins into the vending machine and then enter the two character item code of their
selection. If the user has inserted enough money, the vending machine will release the chosen
item and output any change required. If the user enters an invalid item code then a suitable error
message is displayed.

(a) The vending machine is tested before it is released.

(i) Explain the purpose of testing the vending machine.

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

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

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

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

(ii) Describe the difference between iterative testing and final testing.

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

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

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

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

(iii) Complete the following test plan for the vending machine.

Code entered Money inserted Expected result

B1 £1 Chocolate bar served, £0.10 change given

£0.85 Raisins served, no change given

C1 Error – not enough money inserted

C3 £0.75

[3]

© OCR 2020 Turn over


8
(b) The algorithm for one section of the vending machine program is shown in pseudocode.

if money >= price then

venditem()

giveChange(money – price)

else

print("Error – not enough money inserted")

endif

(i) Give the identifier of one variable used in the algorithm.

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

(ii) State how many parameters are passed into the giveChange() subroutine.

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

© OCR 2020
9
(c) Draw the vending machine algorithm in part (b) as a flowchart.

[5]

© OCR 2020 Turn over


10
(d) When writing the program for the vending machine, maintainability was considered.

(i) Identify two ways that the program in part (b) has been made more maintainable.

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

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

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

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

(ii) Give one additional way that the maintainability of the program can be improved.

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

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

(e) The vending machine stores the quantity of items available in a database table called ITEMS.
The current contents of ITEMS is shown:

ItemCode ItemName Stock


A1 Crisps, bacon flavour 6
A2 Crisps, salted 2
B1 Chocolate bar 12
C1 Apple pieces 18
C2 Raisins 7

Complete the following SQL statement to display the item code for all items that have fewer
than 10 in stock.

SELECT ...................................................................................................................................

FROM .......................................................................................................................................

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

© OCR 2020
11
(f) The vending machine can be in one of three states: on, off or suspended. A user can change
the state of the vending machine by using the following algorithm.

newstate = input("Enter the new state : ")

switch newstate:

case "on":

statevalue = 1

case "off":

statevalue = 2

case "suspended":

statevalue = 3

default:

print("Invalid state")

endswitch

Rewrite the algorithm to perform the same actions using IF statements in place of the switch
statement.

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

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

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

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

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

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

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

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

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

© OCR 2020 Turn over


12
4 (a) Convert the binary value 1110 0011 into hexadecimal.

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

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

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

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

(b) Convert the denary value 105 into an 8 bit binary number.

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

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

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

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

(c) Give two reasons why computer scientists use hexadecimal to represent numbers instead of
binary.

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

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

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

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

(d) DIV and MOD are both operators used in computing-related mathematics.

(i) State the value of 13 DIV 4

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

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

(ii) State the value of 13 MOD 4

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

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

(e) Show the outcome of a right shift of three places on the binary value 0111 1000

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

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

© OCR 2020
13
(f) (i) Draw the logic diagram for the logic system P = A OR (B AND C)

[3]

(ii) Complete the truth table for the logic system P = NOT (A OR B)

A B P

0 0 1

0 1

1 0

[4]

© OCR 2020 Turn over


14
5 The following logo is stored as a bitmap image. Each box represents one pixel, with three different
colours being used in the image.

(a) State what is meant by the term image resolution.

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

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

(b) Calculate the fewest number of bits that could be used to store the logo as a bitmap image.
You must show your working.

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

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

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

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

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

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

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

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

(c) Give two ways that the file size of the image could be reduced.

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

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

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

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

© OCR 2020
15
(d) Metadata is sometimes stored alongside images.

(i) State what is meant by the term metadata.

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

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

(ii) Give one example of metadata that could be stored alongside the logo.

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

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

© OCR 2020 Turn over


16
6 The following names of students are stored in an array with the identifier studentnames.

studentnames = ["Rob", "Anna", "Huw", "Emma", "Patrice", "Iqbal"]

(a) Describe the steps that a linear search would take to find Anna in studentnames

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

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

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

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

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

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

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

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

© OCR 2020
17
(b) The names of students are sorted into ascending alphabetical order using an insertion sort.

Complete the following diagram to show the stages an insertion sort would take to complete
this task.

Each row represents one pass of the insertion sort algorithm. You may not need to use all
empty rows.

Rob Anna Huw Emma Patrice Iqbal

[5]

© OCR 2020 Turn over


18
(c) A school uses the array to call an attendance register every morning.

Write an algorithm using iteration to:

• display the name of each student one at a time from studentnames


• take as input whether that student is present or absent
• display the total number of present students and number of absent students in a suitable
message, after all student names have been displayed.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.............................................................................................................................................. [6]
END OF QUESTION PAPER
© OCR 2020
19
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 2020
20

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 OCR Copyright Team, The Triangle Building, Shaftesbury Road, Cambridge CB2 8EA.
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 2020

You might also like