OCR D1 2010 June — Question 1

Exam BoardOCR
ModuleD1 (Decision Mathematics 1)
Year2010
SessionJune
TopicFixed Point Iteration

1 Owen and Hari each want to sort the following list of marks into decreasing order. $$\begin{array} { l l l l l l l l l l } 31 & 28 & 75 & 87 & 42 & 43 & 70 & 56 & 61 & 95 \end{array}$$
  1. Owen uses bubble sort, starting from the left-hand end of the list.
    (a) Show the result of the first pass through the list. Record the number of comparisons and the number of swaps used in this first pass. Which marks, if any, are guaranteed to be in their correct final positions after the first pass?
    (b) Write down the list at the end of the second pass of bubble sort.
    (c) How many more passes are needed to get the value 95 to the start of the list?
  2. Hari uses shuttle sort, starting from the left-hand end of the list. Show the results of the first and the second pass through the list. Record the number of comparisons and the number of swaps used in each of these passes.
  3. Explain why, for this particular list, the total number of comparisons will be greater using bubble sort than using shuttle sort. Shuttle sort is a quadratic order algorithm.
  4. If it takes Hari 20 seconds to sort a list of ten marks using shuttle sort, approximately how long will it take Hari to sort a list of fifty marks?