Quelpr

CAPE Computer Science Unit 2 · 2012 · Paper 2 · Question 2(b)(i)

A sorted array arr contains 10 integers: indices 0 to 9 with values 7, 9, 16, 22, 27, 45, 50, 51, 80, 91.

Describe how a binary search algorithm will search arr for key 16, showing the portion of the array searched each iteration.

This question uses a figure or table from the paper — you'll see it when you practise.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 2(a)Write C code that takes two integers, lower and upper (where lower < upper), and counts and prints the number of marks in an unsorted array of 100 student…[10 marks]
  2. 2(b)(ii)Describe how a binary search algorithm will search arr for key 63, showing the portion of the array searched each iteration.[6 marks]
  3. 2(c)Draw the array after the first, second, and third passes of the selection sort algorithm (three diagrams in all).[3 marks]

More practice: the rest of this paper · more Searching and Sorting Algorithms questions · all CAPE Computer Science Unit 2 past papers