Question 3
OCR B (MEI) Further Maths November 2020 Modelling with algorithms (Y413-01)AS8 marks
On the specification
- (a)
- A1–A11 Modelling with Algorithms (Y413): Algorithms
- (b)
- A1–A11 Modelling with Algorithms (Y413): Algorithms
- (c)
- A1–A11 Modelling with Algorithms (Y413): Algorithms
- (d)
- A1–A11 Modelling with Algorithms (Y413): Algorithms
Question text
3 The list below shows the sizes of eight items. 32 37 25 18 34 27 15 30 (a) Show the result of applying the first fit algorithm to pack the items into bins that have a capacity of 70. [2] An algorithm for sorting a list of n numbers into descending order is given below. The first pass consists of the following. Compare the second value with the first and swap if necessary (that is if the second value is larger than the first). The second pass consists of the following. Compare the third value with the second and swap if necessary. If a swap happened compare the new second value with the first as in the first pass. The third pass consists of the following. Compare the fourth value with the third and swap if necessary. If a swap happened compare the new third value with the second as in the second pass. Continue in this way for n-1 passes. Starting at the left-hand end of the list the result after each pass through the above algorithm on the original list of eight numbers is shown below. Original list: 32 37 25 18 34 27 15 30 1st pass: 37 32 25 18 34 27 15 30 2nd pass: 37 32 25 18 34 27 15 30 3rd pass: 37 32 25 18 34 27 15 30 4th pass: 37 34 32 25 18 27 15 30 5th pass: 37 34 32 27 25 18 15 30 6th pass: 37 34 32 27 25 18 15 30 7th pass: 37 34 32 30 27 25 18 15 (b) Complete the table in the Printed Answer Booklet showing the number of comparisons and swaps during each pass through the algorithm. [3] (c) Show the result of applying the first fit decreasing algorithm to pack items with the sizes listed above into bins that have a capacity of 70. [2] The number of comparisons is used as a measure of the complexity of the above sorting algorithm. (d) State, in terms of n, the order of the best-case complexity of the sorting algorithm. [1]