Quelpr

CAPE Computer Science Unit 2 · 2015 · Paper 2 · Question 2(c)(ii)

An array named numbers of size 50 is loaded with 50 integers sorted in ascending order.

Write code to search for target in the sorted array numbers using binary search. Print its location if found; otherwise print -1.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 2(a)Draw the array after the first, second, and third passes of selection sort (3 diagrams total).[6 marks]
  2. 2(b)(i)Draw a diagram to show the linked list.[3 marks]
  3. 2(b)(ii)Explain how to delete the integer 3 from the linked list.[4 marks]
  4. 2(c)(i)Write code to obtain the value of an integer, target, from the user.[2 marks]

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