Skip to content

Course home

Searching and sorting algorithms

Searching and sorting algorithms

EasyMedium
12345678910111213141516171819
Question 14

An analyzer has sorted a list of ten chemical elements alphabetically, as shown in the table below.

Index0123456789
ElementArgonBerylliumCarbonFluorineHeliumLithiumNeonOxygenSodiumXenon

Demonstrate the steps of a binary search algorithm to locate the element Neon in this list. At each stage, you must clearly state:

  • the current lower bound L L\,L and upper bound RRR,
  • the calculation used to determine the midpoint index (using the floor division rule ⌊L+R2⌋\displaystyle \lfloor \frac{L + R}{2} \rfloor⌊2L+R​⌋),
  • the pivot element selected,
  • and the comparison that leads to the next interval.
[4]
Markscheme

Searching and sorting algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Searching and sorting algorithms

36 exam-style questions on OCR GCSE Computer Science Searching and sorting algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank