Skip to main content
A-LevelComputer ScienceAlgorithm design and problem-solving9618/31 · Oct/Nov 2022 · Q129 Marks

The array Names [0:99] is in alphabetical order. Complete this pseudocode binary search algorithm. Lower ← 0 Mid ← 0 Exit ← FALSE OUTPUT "Enter the name to be found " INPUT Target REPEAT OUTPUT Target, " does not exist" Exit ← TRUE ENDIF Mid ← Lower + (Upper – Lower + 1) DIV 2 IF Names [Mid] < Target THEN ENDIF IF Names [Mid] > Target THEN ENDIF OUTPUT Target, " was found at location ", Mid Exit ← TRUE ENDIF

  1. (a)The array Names [0:99] is in alphabetical order. Complete this pseudocode binary search algorithm. Lower ← 0 Mid ← 0 Exit ← FALSE OUTPUT "Enter the name to be found " INPUT Target REPEAT OUTPUT Target, " does not exist" Exit ← TRUE ENDIF Mid ← Lower + (Upper – Lower + 1) DIV 2 IF Names [Mid] < Target THEN ENDIF IF Names [Mid] > Target THEN ENDIF OUTPUT Target, " was found at location ", Mid Exit ← TRUE ENDIF[6]
  2. (b)(i)Big O notation is used to classify efficiency of algorithms. The Big O notation for time complexity in a binary search is O(log n). State the Big O notation for time complexity of a linear search.[1]
  3. (b)(ii)Describe the meaning of O(log n) as it applies to a binary search algorithm.[2]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.

  1. [6] One mark for each point (Max 6)
  2. • Initialisation of upper bound
  3. • Test if upper bound is less than lower bound
  4. • Re-setting of mid value if current value is lower than the target
  5. • Re-setting of mid value if current value is higher than the target
  6. • Finding the value
  7. • Correct termination of loop
  8. Lower ← 0 Upper ← 99 Mid ← 0 Exit ← FALSE OUTPUT "Enter the name to be found " INPUT Target REPEAT IF Upper < Lower THEN OUTPUT Target, " does not exist" Exit ← TRUE ENDIF Mid ← Lower + (Upper – Lower + 1) DIV 2 IF Names [Mid] < Target THEN Lower ← Mid + 1 ENDIF IF Names [Mid] > Target THEN Upper ← Mid - 1 ENDIF IF Names [Mid] = Target THEN OUTPUT Target, " was found at location ", Mid Exit ← TRUE ENDIF UNTIL Exit // UNTIL Exit = TRUE
  9. [1] O(n)
  10. [2] One mark for each point (Max 2)
  11. • O(log n) is a time complexity that uses logarithmic time.
  12. • The time taken goes up linearly as the number of items rises exponentially
  13. • O(log n) is the worst case scenario (time complexity for a binary search).

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Algorithm design and problem-solving, A-Level Computer Science (syllabus 9618). Structured question, 9 marks.
Source
A-Level Computer Science, Oct/Nov 2022 Paper 3 Variant 1, question 12.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep