Past-paper question · 2025 October-November · Paper 42 · Q2(e)

Question 2(e) 2025 · October-November · Paper 42 · 6 marks

Original past-paper question for 2(E)
Original past-paper question for 2(E)
Original past-paper question for 2(E)
Reveal official mark-scheme answer Official mark-scheme answer for 2(E)

Official answer for Question 2

Part (e)

Question 1

mark each

Question 6

  • Function header (and end) taking four parameters and recursive function written
  • Calculating middle value
  • Comparing middle value to data parameter and returning index if equal
  • If middle is greater than, recursive call with middle –1 for upper
  • If middle is less than, recursive call with middle + 1 for lower
  • Checking if not found and returning –1
✓
Example program code
✓
Java
✓
public static Integer RecursiveBinarySearch(Integer[] DataArray, Integer Lower, Integer
✓
Upper, Integer DataToFind){
✓
Integer Middle;
✓
if(Upper >= Lower){
✓
Middle = Lower + (Upper - Lower) / 2;
✓
if(DataArray[Middle] == DataToFind){
✓
return Middle;
✓
}else if(DataArray[Middle] > DataToFind){
✓
return RecursiveBinarySearch(DataArray, Lower, Middle - 1, DataToFind);
✓
}else{
✓
return RecursiveBinarySearch(DataArray, Middle + 1, Upper, DataToFind);
✓
}
✓
}else{
✓
return -1;
✓
}
✓
}
✓
9618/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
October/November 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_w25_ms_42.pdf →

Show text version of question

Question 2

Part (e)

Question 2

A program stores 20 unique random integers between 0 and 100 (inclusive) in a 1D array that is

local to the main program.

Part (e)

The recursive function RecursiveBinarySearch() takes four parameters:

  • an integer array
  • the lower bound of the array
  • the upper bound of the array
  • the value to find in the array.

The recursive function performs a binary search to find the index of the value in the array.

The function returns the index of the value if it is found. The function returns –1 if the value is not found.

Write program code for RecursiveBinarySearch()

Save your program.

Copy and paste the program code into part 2(e) in the evidence document.

[6]

Question 8

Topic relevance

Why this question appears here

98% assigned-topic match · Computational thinking and problem-solving › Recursion

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9618_w25_qp_42.pdf

Keep practising this topic