Question 2
OCR B (MEI) Further Maths June 2018 Decision mathematics 1 (4771-01)Older specification8 marks
On the specification
- (a)(i)
- A10-A11 Modelling with Algorithms: Packing algorithms
- (a)(ii)
- A10-A11 Modelling with Algorithms: Packing algorithms
- (b)(i)
- A7-A9 Modelling with Algorithms: Sorting algorithms
- (b)(ii)
- A7-A9 Modelling with Algorithms: Sorting algorithms
Question text
2 (a) Six parcels, A to F, with weights given in the table are to be packed into crates. Each crate has a capacity of 10 kg. Parcel A B C D E F Weight (kg) 1 6 4 2 3 4 (i) Use the first-fit algorithm to pack the parcels, saying how many crates are used. [3] (ii) Give an optimal solution. [1] (b) In the first pass of a bubble sort the first item is compared to the second item and they are swapped if they are in the incorrect order, then the second is compared with the third and they are swapped if necessary, and so on until the penultimate is compared to the last and they are swapped if necessary. In the second pass the process is repeated, but without the need to compare the last two items, and similarly for subsequent passes. In the final pass, only the two items in the first two positions are compared and swapped if necessary. In a sale, a coat costs £78, a pair of gloves cost £26, a hat costs £35 and a scarf costs £12. (i) Use a bubble sort to rearrange the items from the order given into increasing order of price. Show the list of costs after each pass of the algorithm. [2] (ii) How many comparisons and how many swaps were made in answering part (i)? [2]