Algorithms, bin packing and sortingEdexcel A-Level Further Maths: Subtopic test
10 questions, 27 marks
Edexcel A-Level Further Maths
Algorithms, bin packing and sorting
Total 27 marks
Name
Class
Date
- 1The following algorithm is applied to two positive integers and , where . Step 1: input and . Step 2: let be the remainder when is divided by . Step 3: if , output and stop. Step 4: replace by and replace by . Step 5: go back to Step 2.(a)Find the output when the algorithm is applied to and .[1 mark]
- A
- B
- C
- D
(b)The algorithm is applied to and . How many times is Step 2 performed?[1 mark]- A
- B
- C
- D
(c)State what the algorithm finds, and explain why it must eventually stop.[2 marks]Total for question 1: 4 marks
- 2Nine files of sizes 7, 13, 8, 3, 5, 9, 4, 14 and 12 MB are to be saved on memory cards, each of capacity 20 MB. A file cannot be split between cards.(a)What is the lower bound on the number of cards needed?[1 mark]
- A
- B
- C
- D
(b)The files are saved using the first-fit algorithm, in the order given. How many cards are used?[1 mark]- A
- B
- C
- D
(c)Use the first-fit decreasing algorithm to pack the files. State the number of cards used and the contents of each.[2 marks]Total for question 2: 4 marks
- 3The list 23, 8, 31, 15, 4, 19, 27 is to be sorted into ascending order using quick sort. The pivot is always the middle item of the list or sublist: in position if is odd and if is even. Items smaller than the pivot go to its left and larger items to its right, each keeping their original order.(a)Show the result of the first pass of quick sort, stating the pivot used.[3 marks](b)Complete the quick sort, showing each pivot used.[4 marks]
Total for question 3: 7 marks
- 4The following algorithm sorts a list of different numbers into ascending order. Step 1: set equal to . Step 2: compare each pair of adjacent items in the first positions of the list, working from left to right, and swap the two items in a pair if they are in the wrong order. Step 3: reduce by 1. Step 4: if , stop; otherwise go back to Step 2.(a)Apply the algorithm to the list 8, 3, 6, 2, 5, showing the list at the end of each pass. State the total number of comparisons and the total number of swaps.[6 marks](b)The algorithm takes 2 ms to sort a list of 40 items on a computer. Find the number of comparisons used for 40 items, state the order of the algorithm, and estimate the time to sort a list of 400 items. Comment on the reliability of your estimate.[6 marks]
Total for question 4: 12 marks
End of questions
Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).