Question 4

OCR B (MEI) Further Maths June 2022 Modelling with algorithms (Y433-01)A level5 marks

On the specification

(a)
A7-A9 Modelling with Algorithms: Sorting algorithms
(b)
A7-A9 Modelling with Algorithms: Sorting algorithmsN13 Modelling with Algorithms: Solving network problems using technology
(c)
A7-A9 Modelling with Algorithms: Sorting algorithms
Question text

4 A list of n numbers is to be sorted into descending order using the quick sort algorithm. The number of comparisons made in each pass of the algorithm is used as a measure of the complexity of the quick sort algorithm. 2 (a) Show that, in the worst case, the quick sort algorithm has complexity O(n ). [2] -7 (b) A computer takes 2 3. #10 seconds to sort the list of 100 ascending integers 1, 2, 3…, 99, 100 into descending order using the quick sort algorithm. Calculate approximately how long it will take the computer to sort the list of 500 000 ascending integers 1, 2, 3,…, 499 999, 500 000 into descending order using the quick sort algorithm. You should assume that the computer uses the first value as the pivot for each sublist. [2] A student attempts to use the quick sort algorithm to sort a list of seven random integers into descending order. After two passes through the list the student produces the following list. 68 10 5 7 11 4 (c) Explain how you know that the student has made at least one error in these two passes. [1]