Question Paper Computational Thinking Algorithms and Programming
Question Paper Computational Thinking Algorithms and Programming
• a calculator
* J 2 7 6 0 2 *
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.
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 ..................
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
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.
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
7
3 A vending machine has the following options available.
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.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(ii) Describe the difference between iterative testing and final testing.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(iii) Complete the following test plan for the vending machine.
C3 £0.75
[3]
venditem()
giveChange(money – price)
else
endif
...................................................................................................................................... [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]
(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:
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.
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]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [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.
...........................................................................................................................................
...................................................................................................................................... [1]
...........................................................................................................................................
...................................................................................................................................... [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]
...................................................................................................................................................
.............................................................................................................................................. [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.
...........................................................................................................................................
...................................................................................................................................... [1]
(ii) Give one example of metadata that could be stored alongside the logo.
...........................................................................................................................................
...................................................................................................................................... [1]
(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.
[5]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [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
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
© OCR 2020