Docsity

OCR - GCSE (9-1) Computer Science - J277/02 Computational thinking, algorithms and program, Exams of Computer Science

Partial preview of the text

Download OCR - GCSE (9-1) Computer Science - J277/02 Computational thinking, algorithms and program and more Exams Computer Science in PDF only on Docsity!

Oxford Cambridge R Tuesday 20 May 2025 — Afternoon GCSE (9-1) Computer Science J277/02 Computational thinking, algorithms and programming Time allowed: 1 hour 30 minutes Do not use: * a calculator 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. + We advise you to spend approximately 50 minutes on Section A and approximately 40 minutes on Section B. © OCR 2025 [601/8355/X] OCR is an exempt Charity DC (WW/JG) 3558173 Turn over 2 Section A We advise you to spend approximately 50 minutes on Section A. A program asks a user to enter a number. Only integer values between 1 and 100 (inclusive) are accepted. The program is tested. (a) Tick (Vv) one or more boxes in each row to identify the type or types of test for each example of test data. Invalid / erroneous test data Example Normal Boundary test data test data test data 27 "Hello" 105 100 [4] (b) An algorithm is written for the program. (i) Complete the algorithm for the program. num = input ("Enter a number between 1 and 100") if num. print ("accepted") print ("not accepted") endif [3] (ii) Give the identifier of one variable used in the algorithm in part (b)(i). ©OCR 2025 2 This flowchart uses iteration. Start | INPUT x | x=x- 2 (a) Complete the table by identifying how many times "OK" will be output for when each value is input. Input value Number of times "0K" is output 3 10 [2] (b) Iteration is a programming construct. (i) Identify and describe two different examples of iteration that can be used in a high-level language. WV ee ceseeeecesesceseessecsesuesencsueece cesses cesses sessuee cesses esaususeusuucsassuecsussuceeseuese senses cesuesseassuessuessssneseessneesseneseeenee DQ cecceeecsecsecsecseeesceseesessueseseeousuessucsueeeceueseussuceeceusesecsussessues esses seseuesueeassuessucouee cesses eeeasessesessieseseneeeeeeceeeee [4] © OCR 2025 Turn over 3 (a) Show the steps that a merge sort would take to put the data set into ascending numerical order. 2, 7, 3, 1, 9, 6, 5, 4 ©OCR 2025 Turn over [4] 6 (b) Tick (V) one box in each table to complete the descriptions. An insertion sort... Tick (V) one box uses an array of numbers with a sorted part and unsorted part picks out the middle value to begin with merges arrays of numbers together A bubble sort compares pairs of values and then: Tick (V) one box always swaps them swaps them if they are in the correct order swaps them if they are in the incorrect order Asorting algorithm can sort data in an array. An array: Tick (V) one box is declared with a fixed length stores multiple values that cannot be changed while the program is running can only be declared with a maximum of one-dimension (1D) [3] (c) An algorithm can be used to search for a value in an array. The algorithm follows these steps: * compares the first value in the array to the value being searched for + stops if the comparison is true * moves to the next value in the array if the comparison if false. (i) Give the name of the searching algorithm described. oc cessovstus ston stunssusssonesssniitstonstarestunstanssnistinstinstssestusestinestinestssestiseesteneesseneesseneeee [1] (ii) Identify one other condition that will cause the algorithm to stop. De [1] ©OCR 2025 8 5 Asecurity system protects online credit card payments. The system has three inputs: Input Description A True when the user enters their correct password B True when the user enters their correct PIN c True when the card is blocked The output (2) is True if both of the following conditions are True: + the user has entered either their correct password or has entered their correct PIN + the card is not blocked. (a) Draw the logic circuit for the security system [3] (b) Complete the truth table for P= A AND B A B P ©OCR 2025 9 (c) Computational thinking techniques were used to design the security system. Draw one line to match each computational thinking technique to its correct example. ©OCR 2025 Computational thinking technique Abstraction Decomposition Algorithmic thinking Example The system is broken down into modules for security and payments. There is an increase in the amount of RAM in the computer running the system The user’s identity, PIN and password are required. All other data is ignored. The step-by-step process for users to securely pay online is designed. Turn over [3] 11 Section B We advise you to spend approximately 40 minutes on Section B. Some questions require you to respond using either the OCR Exam Reference Language or a (a) (i) high-level programming language you have studied. These are clearly shown. OCR Rockfest is a yearly music festival. Visitors buy tickets to attend and watch the music acts. Acomputer system is created to sell tickets and store information about visitors and the music acts. Visitors are asked to choose a password. The password is entered twice and stored in the variables passA and passB Tick (V) one box to identify the correct OCR Exam Reference Language statements for the design of this task. OCR Exam Reference Language to enter two passwords Tick (V) one box passA and passB = input("enter password twice") input ("enter your password") — passA input ("enter your password again") = passB passA = input ("enter your password") passB = input ("enter your password again") input ("enter your password") input ("enter your password again") "passA" "passB" (ii) Design an algorithm that: checks if the passwords stored in passa and passB are the same outputs "passwords match" if they are the same outputs "passwords do not match" if they are not the same. [1] 1 (b) The database table ToblMusic stores data about the music acts. Some of the data in Tb1Music is shown: ActID Stage Day SetLength 1 Platinum Saturday 0.5 2 Hills Saturday 1.5 3 Triangle Sunday 1.0 4 Platinum Sunday 0.5 An SQL statement has been written to show Act ID and Stage for all acts playing on Saturday. The SQL statement is incorrect. SELECT ActID AND Stage FROM TblActs IF Day = Saturday (i) Refine the SQL statement to correct the errors. (iii) Give the most appropriate data type for each field shown. Field name Data stored Data type Stage The name of the stage SetLength The length of each set in hours ©OCR 2025 1 (d) The number of different music acts on each of the three stages is stored in the array actNumbers. Each index of the array represents one stage. Index 0 1 2 Data 10 14 6 actNumbers This algorithm adds up the total number of acts on all three stages. 01 count = 0 02 for x = 0 to 2 03 count = 04 next x 05 print (count) (i) Complete the trace table for the algorithm. You may not need to use all rows in the table. count + actNumbers [x] Line number count x Output ©OCR 2025 [4] 15 (ii) The array actNumbers is changed to include data for two more stages. The new array is shown: Index 0 1 2 3 4 Data 10 14 6 9 11 actNumbers The algorithm from part (i) needs refining to work for the new array. The algorithm is repeated here: 01 count = 0 02 for x = 0 to 2 03 count = count + actNumbers[x] 04 next x 05 print (count) Identify the line number that will need to be changed for the new array and write the updated line of code. LIM© MUMDEL one eee eeceseceeeeeseee concen eeseee conten cee pene eceesesaneeassneaseceuseaseceaseasaseaeeceaseneaeeneeeeeteneess Updated Code oo.eeeceeeeeecccccceccecseecseseeeeseseeceeceesceeseeceuceesceescecseeceusecscecseacseeesececseecseeseeseseeeeseenseeessee sees (iii) Refine line 05 in the algorithm to output "The total act count is "and then the content of the variable count For example: The total act count is 50 NOW Fin@ 05 once cece cece eeceee cece seeeee eeseseesnsens eeeesensneeceasenanseaseseusensnseaseneaseseaseeseneaseneaseseusentueeaeeeeetes © OCR 2025 Turn over 17 EXTRA ANSWER SPACE If you need extra space use these lined pages. You must write the question numbers clearly in the margin.