
























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
2O25 OCR A Level Computer Science H446/02 Algorithms and programming Verified Question paper with Marking Scheme combined 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.
Typology: Exams
1 / 64
This page cannot be seen from the preview
Don't miss anything!

























































Oxford Cambridge and RSA Wednesday 18 June 2025 – Morning A Level Computer Science
Time allowed: 2 hours 30 minutes You can use:
(b) A second type of sorting algorithm is an insertion sort. Describe how an insertion sort can be used to put the following data into ascending order. 20 8 15 36 .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ..................................................................................................................................................... [5] © OCR 2025 Turn over
(c) A third type of sorting algorithm is a quick sort. 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. 1 function partition(array, low, high) 2 pivot = array[high] 3 index = low - 1 4 for count = low to high- 1 5 if array[count] < pivot then 06 index = index + 1 07 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 (i) 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 ............................................................................................................. [2] © OCR 2025
2* A shopping website requires customers to create a username and password. (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:
(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. .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ..................................................................................................................................................... [3] (ii) Explain how the company can make use of data mining to improve their website and customer experience. .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ..................................................................................................................................................... [2] © OCR 2025 Turn over
3 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 1 0 "I" "n" "k" 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 = ................... [2] © OCR 2025 Turn over
(b) The stack is 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 true 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) if pointer == ..................................................................... then return false else pointer = ..................................................................... theStack[pointer] = ..................................................................... ..................................................................... endif endfunction [4] © OCR 2025
4* 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:
© OCR 2025 Turn over
(b) A user 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 Final path: ........................................................................................................................................ Distance: .......................................................................................................................................... [7] © OCR 2025 Turn over
(c) The A* algorithm can also be used to find the shortest path in a graph. Describe how an A* algorithm uses heuristics to be an efficient algorithm. .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ..................................................................................................................................................... [2] 6 A student 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
(d) An algorithm is needed to count how many times each of the numbers from 1 to 9 appear in an array called myArray. Another array called checked is used to store each number found in myArray and the number of times it appears. For example, the contents of myArray are: 7 3 6 7 5 3 2 3 6 Based on these contents in myArray, the contents in checked would be: 7 2 3 3 6 2 5 1 2 1
Identify the line number of any four errors and write the corrected line for each error. Error 1 Line number ................... Corrected line ................................................................................................................................... Error 2 Line number ................... Corrected line ................................................................................................................................... Error 3 Line number ................... Corrected line ................................................................................................................................... Error 4 Line number ................... Corrected line ................................................................................................................................... [4] © OCR 2025 Turn over