AQA D1 2007 January — Question 4

Exam BoardAQA
ModuleD1 (Decision Mathematics 1)
Year2007
SessionJanuary
TopicSorting Algorithms

4
  1. A student is using a bubble sort to rearrange seven numbers into ascending order.
    Her correct solution is as follows:
    Initial list18171326101424
    After 1st pass17131810142426
    After 2nd pass13171014182426
    After 3rd pass13101417182426
    After 4th pass10131417182426
    After 5th pass10131417182426
    Write down the number of comparisons and swaps on each of the five passes.
  2. Find the maximum number of comparisons and the maximum number of swaps that might be needed in a bubble sort to rearrange seven numbers into ascending order.