Partial preview of the text
Download OCR A Level Computer Science H446/02 Algorithms and programming 2026 Combined Question and more Exams Medicine in PDF only on Docsity!
OCR A Level Computer Science H446/02 Algorithms and programming 2026 Combined Question Paper and Final Marking Scheme Oxford Cambridge R Wednesday 18 June 2025 — Morning A Level Computer Science H446/02 Algorithms and programming Time allowed: 2 hours 30 minutes You can use: * aruler (cm/mm) * an HB pencil Do not use: * a calculator ANT : Please write clearly in black ink. Do not write in the barcodes. Centre number Candidate number First name(s) Last name XN INSTRUCTIONS + Use black ink. You can use an HB pencil, but only for graphs and diagrams. + Write your answer to each question in the space provided. If you need extra space use the lined page 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 140. + The marks for each question are shown in brackets [ ]. * Quality of extended response will be assessed in questions marked with an asterisk (*). + This document has 32 pages. ADVICE + Read each question carefully before you start your answer. (b) Asecond type of sorting algorithm is an insertion sort. 3 Describe how an insertion sort can be used to put the following data into ascending order. 20 15 36 ©OCR 2025 Turn over 4 (c) A third type of sorting algorithm is a quick sort. (i) The following quick sort algorithm is made up of two functions called partition() and quickSort (). The algorithm will sort an integer array into ascending numerical order. o1 function partition(array, low, high) 02 pivot = array[high] 03 index = low - 1 04 for count = low to high-1 05 if array[count] < pivot then 06 index index + 1 o7 temp = array[index] 08 array[index] = array[count] 09 array[count] = temp 10 endif 11 next count 12 temp = array[index + 1] 13 array[index + 1] = array[high] 14 array[high] = temp 15 return index + 1 16 endfunction 17 18 function quickSort (array, low, high) 19 if low < high then 20 partitionIndex = partition(array, low, high) 21 quickSort (array, low, partitionIndex - 1) 22 quickSort (array, partitionIndex + 1, high) 23 endif 24 endfunction Identify which of the two functions is recursive and give all of the line numbers where recursive calls are made. Recursive function name Recursive call line numbers ©OCR 2025 2* Ashopping website requires customers to create a username and password. 6 (a) The usernames and passwords are stored securely in a file. The file contains the username and passwords for 50 million users which are sorted in alphabetical order by username. The file can be searched using a linear search or a binary search. The big-O complexities for a linear search and a binary search are given in the table: Search Worst-case Average-case Worst-case algorithm time time space Linear O(n) O(n) O(1) Binary O(log n) O(log n) O(1) Compare the use of a linear search and a binary search in this scenario. You should include the following in your answer: + the features and preconditions of a linear and binary search + the benefits and drawbacks of each search in this scenario + aconclusion justifying which search algorithm should be used in this scenario. You should make reference to the big-O complexities in your answer. ©OCR 2025 (b) The website collects data from customers’ activities once they log on. For example, the items they view and purchase. The company that owns the website would like to use data mining to improve their website and customer experience. (i) Describe what data mining means. (ii) Explain how the company can make use of data mining to improve their website and customer experience. © OCR 2025 Tum over 9 A program is designed to use a stack data structure. The current contents of part of the stack and its current pointer value are shown: 5 4 3 2 v 1 "n" 0 "" pointer = 2 (a) Show the contents of the stack and its pointer value after the data items "t" and "s" are inserted in the order given. 5 4 3 2 1 0 pointer = .... ee [2] © OCR 2025 Tum over 10 (b) The stackis stored using a 0-based 1-dimensional array called thestack with 20 elements. The function push () stores its parameter into the next space in the stack if it is not full. The function returns t rue if it is successfully stored and returns false if the stack is full. Complete the function push () using pseudocode or program code. function push (data) Af pointer ==. ee eee ene then return false else pointer = theStack[pointer] = endif endfunction ©OCR 2025 [4] 4 12 A processor is being designed to use pipelining and will need to be able to process millions of instructions. For each instruction the following stages will be performed: A _ the instruction will be fetched from memory B the instruction will be decoded C __ the instruction will be executed The first four instructions to be processed will be instructions 1, 2, 3 and 4. The design allocates 1-time interval for each of the three stages A, B, C. Discuss the use of pipelining by this processor. You should include the following in your answer: + the features of pipelining + how pipelining can be used to manage the first four instructions * aconclusion justifying the use of pipelining in this scenario. [9] 13 © OCR 2025 Tum over 15 (b) Auser needs to travel from planet A to planet H. They need to travel the least expensive route. Show how Dijkstra’s algorithm can be used on the directed graph shown in Fig. 5 to find the shortest path from start planet A to the end planet H. You must state the nodes on the final path and the distance of this path. Show your working. You may use the table to give your answer. Node Distance travelled Previous node Firal path: oe. ccee cece eeseceeeeeceeecseceseceescecsessucasscecessncsseceucecscecsaeceuseeseeeseacseeceeseseeceeseeeeteeesee Distance: © OCR 2025 Tum over 1€ (c) The A* algorithm can also be used to find the shortest path ina graph. Describe how an A* algorithm uses heuristics to be an efficient algorithm. oc eessesestosssusstunstonnstosstunesssnstinestunestonstsnstinstonstitestinestinestisestinessestestineestaneeseeeees [2] 6 Astudent is writing a program in a high-level programming language. (a) The student writes the program using an Integrated Development Environment (IDE). Complete the table by identifying and describing three features of an IDE that the student can use to debug their program. Debugging feature Description [6] ©OCR 2025