Skip to content

Course home

Searching and sorting algorithms

Searching and sorting algorithms

EasyMedium
12345678910111213141516171819
Question 2

A geologist is searching for a mineral specimen with a specific density of 8.4 g/cm3 from a sorted list of 11 measured densities:

[2.1,2.8,3.5,4.2,4.9,5.6,6.3,7.0,7.7,8.4,9.1] [2.1, 2.8, 3.5, 4.2, 4.9, 5.6, 6.3, 7.0, 7.7, 8.4, 9.1] [2.1,2.8,3.5,4.2,4.9,5.6,6.3,7.0,7.7,8.4,9.1]

Using the binary search algorithm with indices 1 to 11, and calculating the midpoint index using the formula ⌊L+R2⌋\displaystyle \lfloor \frac{L+R}{2} \rfloor⌊2L+R​⌋ (where L L\,L and R R\,R represent the lower and upper bounds of the current search space), demonstrate how the target density of 8.4 g/cm3 is located. For each step, identify the midpoint index and its value, show the comparison with the target, and state the remaining list of densities.

[3]
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