Computer Science > QUESTIONS & ANSWERS > OCR Oxford Cambridge and RSA Friday 27 May 2022 -Afternoon GCSE (9—1) Computer Science J277102 Com (All)

OCR Oxford Cambridge and RSA Friday 27 May 2022 -Afternoon GCSE (9—1) Computer Science J277102 Computational thinking, algorithms and programming Time allowed: 1 hour 30 minutes

Document Content and Description Below

Answer all the questions. SECTION A 1 (a) Tick (3) one box in each row to identify whether the OCR Reference Language code given is an example of selection or iteration. OCR Reference Language co... de Selection Iteration for i = 1 to 10 print(i) next i while score != 0 playgame() endwhile if playerHit() then score = 0 endif switch bonus: case 0: score = 9 case 1: score = 7 case 2: score = 5 endswitch [4] (b) Write pseudocode to increment the value held in the variable score by one. ................................................................................................................................................... .............................................................................................................................................. [1] (c) State the name of each of the following computational thinking techniques. Breaking a complex problem down into smaller problems. ................................................................................................................................................... ................................................................................................................................................... Hiding or removing irrelevant details from a problem to reduce the complexity. ................................................................................................................................................... ................................................................................................................................................... [2] 3 © OCR 2022 Turn over 2 A fast food restaurant offers half-price meals if the customer is a student or has a discount card. The offer is not valid on Saturdays. A computer system is used to identify whether the customer can have a half-price meal. The table identifies the three inputs to the computer system: Input Value A Is a student B Has a discount card C The current day is Saturday (a) The logic system P = (A OR B) AND NOT C is used. (i) Complete the following logic diagram for P = (A OR B) AND NOT C by drawing one logic gate in each box. A C B P [3] (ii) A truth table can be produced for this logic circuit. Describe the purpose of a truth table. ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ...................................................................................................................................... [2] (iii) State how many rows (excluding any headings) would be required in a truth table for the logic expression: P = (A OR B) AND NOT C ...................................................................................................................................... [1] 4 © OCR 2022 (b) The restaurant needs an algorithm designing to help employees work out if a customer can have a half price meal or not. It should: • input required data • decide if the customer is entitled to a discount • output the result of the calculation. Design the algorithm using a flowchart. [5] 5 © OCR 2022 Turn over (c) The restaurant adds a service charge to the cost of a meal depending on the number of people at a table. If there are more than five people 5% is added to the total cost of each meal. Customers can also choose to leave a tip, this is optional and the customer can choose between a percentage of the cost, or a set amount. Identify all the additional inputs that will be required for this change to the algorithm. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... .............................................................................................................................................. [2] 6 © OCR 2022 (d) Each member of staff that works in the restaurant is given a Staff ID. This is calculated using the following algorithm. 01 surname = input("Enter surname") 02 year = input("Enter starting year") 03 staffID = surname + str(year) 04 while staffID.length < 10 05 staffID = staffID + "x" 06 endwhile 07 print("ID " + staffID) (i) Define the term casting and give the line number where casting has been used in the algorithm. Definition ........................................................................................................................... ........................................................................................................................................... Line number ...................................................................................................................... [2] (ii) Complete the following trace table for the given algorithm when the surname “Kofi” and the year 2021 are entered. You may not need to use all rows in the table. Line number surname year staffID Output 01 Kofi 02 2021 [4] 7 © OCR 2022 Turn over 3 A program stores the following list of positive and negative numbers. The numbers need sorting into ascending order using a merge sort. 45 12 –99 100 –13 0 17 –27 (a) The first step is to divide the list into individual lists of one number each. This has been done for you. Complete the merge sort of the data by showing each step of the process. 45 12 –99 100 –13 0 17 –27 [3] 8 © OCR 2022 (b) Once the numbers are in order, a binary search can be run on the data. Describe the steps a binary search will follow to look for a number in a sorted list. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... .............................................................................................................................................. [4] (c) A linear search could be used instead of a binary search. Describe the steps a linear search would follow when searching for a number that is not in the given list. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... .............................................................................................................................................. [2] 9 © OCR 2022 Turn over 4 Jack is writing a program to add up some numbers. His first attempt at the program is shown. a = input("Enter a number") b = input("Enter a number") c = input("Enter a number") d = input("Enter a number") e = input("Enter a number") f = (a + b + c + d + e) print(f) (a) Give two ways that the maintainability of this program could be improved. 1 ................................................................................................................................................ ................................................................................................................................................... 2 ................................................................................................................................................ ................................................................................................................................................... [2] (b) Jack’s program uses the addition (+) arithmetic operator. This adds together two numbers. (i) State the purpose of each of the arithmetic operators in the table. Arithmetic operator Purpose * / [2] 10 © OCR 2022 (ii) Complete the description of programming languages and translators by writing the correct term from the box in each space. continues crashes debugging error executable high-level interpreter language low-level many no one stops with without Jack writes his program in a ........................................ language. This needs to be translated into assembly or machine code before it can be executed. This is done using a translator. One type of translator is an interpreter. This converts one line of code and then executes it, before moving to the next line. It ........................................ when an error is found, and when corrected continues running from the same position. This translator is helpful when debugging code. A second type of translator is a compiler. This converts all of the code and produces an error report. The code will not run until there are ........................................ errors. The ........................................ file produced can be run ... [Show More]

Last updated: 1 year ago

Preview 1 out of 20 pages

Add to cart

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

We Accept:

We Accept

Reviews( 0 )

$7.00

Add to cart

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

OR

REQUEST DOCUMENT
46
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 02, 2023

Number of pages

20

Written in

Seller


seller-icon
Cate

Member since 1 year

0 Documents Sold


Additional information

This document has been written for:

Uploaded

Apr 02, 2023

Downloads

 0

Views

 46

Document Keyword Tags

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·