Quelpr

CAPE Computer Science Unit 2 · 2015 · Paper 2 · Question 2(a)

Consider the array named data containing 8 integers: [10, 13, 8, 15, 16, 6, 22, 4]. A selection sort is used to sort the array into ascending order.

Draw the array after the first, second, and third passes of selection sort (3 diagrams total).

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(b)(i)Draw a diagram to show the linked list.[3 marks]
  2. 2(b)(ii)Explain how to delete the integer 3 from the linked list.[4 marks]
  3. 2(c)(i)Write code to obtain the value of an integer, target, from the user.[2 marks]
  4. 2(c)(ii)Write code to search for target in the sorted array numbers using binary search. Print its location if found; otherwise print -1.[10 marks]

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