Docsity

AS Level Computer Science Exam Paper - Algorithms and Problem Solving, Exams of Computer Science

Partial preview of the text

Download AS Level Computer Science Exam Paper - Algorithms and Problem Solving and more Exams Computer Science in PDF only on Docsity!

Oxford Cambridge and RSA - 2025

Monday 19 May 2025 – Afternoon

AS Level Computer Science

H046/02 Algorithms and problem solving

Time allowed: 1 hour 15 minutes

(Verified Question Paper With Mark

Scheme Combined June 2025)

INSTRUCTIONS

  • Use black ink.
  • 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 70.
  • 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 16 pages. ADVICE
  • Read each question carefully before you start your answer. © OCR 2025 [601/5030/0] DC (KS) 324952/ OCR is an exempt Charity (^) Turn over

© OCR Turn over

BLANK PAGE

DO NOT WRITE ON THIS PAGE

© OCR 2 Players in a computer game collect items. Each item has a name, e.g. “Fruit” and a type, e.g. “Apple”. The items for player 1 are stored in a 2D array. The array is 0-indexed. The pseudocode declaration for the array is: array p1Items[10,2] The first dimension stores the item name and the second dimension stores the type. (a) One characteristic of the array is that it has 2 dimensions. Identify two other characteristics of the given array. 1 .......................................................................................................................................... ............. ............................................................................................................................................ .............. 2 .......................................................................................................................................... ............. ............................................................................................................................................ .............. [2] (b) When the game starts, the pseudocode procedure initialiseArray will initialise each name and type in the array to "empty". 01 procedure initialiseArray(p1Items:byRef) 02 counter = 0 03 while counter < 10 04 p1Items[counter, 0] = "empty" 05 p1Items[counter, 1] = "empty" 06 counter = counter + 1 07 endwhile 08 endprocedure (i) State why empty is in speech marks on lines 04 and 05. ............................................................................................................................................ .............. .................................................................................................................................. [1] (ii) Rewrite the code in lines 02 to 07 to use a for loop instead of a while loop. Write your answer using pseudocode or program code.

© OCR (iii) State one reason why the array should be passed by reference and not by value. ............................................................................................................................................ .............. .................................................................................................................................. [1] (c) When a user collects an item, the name and type are added to the array p1Items. At the end of the game, the name of each item collected is output. Write an algorithm, using pseudocode or program code, to:

  • output the name of each item in the array
  • output a suitable message if there are no items in the array. If the item is "empty" it should not be output. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ ..............

© OCR^ Turn^ over

.................................................................................................................................. [6]

© OCR Turn over Additional space for question 3 if required. data

x item y 0 1 2 3 4

© OCR 4* A group of four students have decided to create a computer program to help teach younger children how to write programs in a text-based language. (a) They intend to divide the program into sub programs that they will develop individually before combining them together to form the final solution. The students are considering the agile methodologies or the waterfall lifecycle. Compare the use of the agile methodologies and waterfall lifecycle for the students’ project. You should include the following in your answer:

  • features of each software development methodology
  • benefits of each software development methodology in this scenario
  • drawbacks of each software development methodology in this scenario. [9] ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................

© OCR

(b) The students intend to use both black-box testing and white-box testing. Give one difference between black-box testing and white-box testing. ............................................................................................................................................ .............. ............................................................................................................................................ .............. .................................................................................................................................. [1]

© OCR Turn over 5 A programmer has been given this pseudocode algorithm. 01 do 02 data = input("Enter the code") 03 until data.length > 20 04 first = data.substring(0,1) 05 second = data.substring(1,1) 06 first = int(first) 07 second = int(second) 08 if first > second then 09 print(str(first) + "wins") 10 elseif first == second then 11 print("It's a draw") 12 else 13 print(second + "wins") 14 endif The pseudocode algorithm calls different subroutines. (a) Identify two subroutines that are called in the pseudocode algorithm. 1 .......................................................................................................................................... ............. ............................................................................................................................................ .............. 2 .......................................................................................................................................... ............. ............................................................................................................................................ .............. [2] (b) Name the programming constructs that start on line 01 and line 08 in the pseudocode algorithm. 01 ......................................................................................................................................... ............. 08 ......................................................................................................................................... ............. [2] (c) State the purpose of line 06. ............................................................................................................................................ ..............

© OCR Turn over (d) The programmer needs to extend the program. The program will use a linear search. (i) The linear search has been written as a pseudocode function that:

  • takes an array called array of an unknown length as a parameter
  • takes a search value called value to search for as a parameter
  • uses a linear search to find the value in the array
  • returns true if the value is found and false otherwise. Complete the pseudocode function. function linearSearch(array,.................) counter = 0 while counter..........array.length if array[counter] == value then return ………………………… endif counter = counter ………………………… endwhile ………………………… ………………………… endfunction [5] (ii) One alternative search algorithm is a binary search. Describe the steps in a binary search. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ ..............

© OCR

.................................................................................................................................. [4]

© OCR (ii) Describe the steps that will be followed to remove an item from the stack. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. .................................................................................................................................. [3] (iii) Complete the function to insert a new data item onto the stack. function push(dataItem) if topPointer ……………………………………………… 7 then return false else topPointer = ……………………………………………… stack[topPointer] = ……………………………………………… return true endif endfunction [3]

© OCR Turn over 7 Write an algorithm, using program code or pseudocode to:

  • take a user’s date of birth as a string input in the format DD/MM/YYYY
  • take a year as input from the user in the format YYYY
  • output the age the user will be on their birthday in the year input in the format: You will be 18 on the 1 January 2029 You can use the function getMonth() to convert a 2-digit month into a string. For example: getMonth(02) will return "February". You do not need to check the inputs are in the correct format. You should assume the year entered will always be in the future. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................ .............. ............................................................................................................................................