All worksheets topics

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

  1. 1
    The following algorithm is applied to two positive integers aa and bb, where a>ba>b. Step 1: input aa and bb. Step 2: let rr be the remainder when aa is divided by bb. Step 3: if r=0r=0, output bb and stop. Step 4: replace aa by bb and replace bb by rr. Step 5: go back to Step 2.
    (a)
    Find the output when the algorithm is applied to a=84a=84 and b=36b=36.
    [1 mark]
    • A3636
    • B1212
    • C2424
    • D66
    (b)
    The algorithm is applied to a=252a=252 and b=105b=105. How many times is Step 2 performed?
    [1 mark]
    • A22
    • B44
    • C33
    • D55
    (c)
    State what the algorithm finds, and explain why it must eventually stop.
    [2 marks]

    Total for question 1: 4 marks

  2. 2
    Nine 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]
    • A33
    • B3.753.75
    • C55
    • D44
    (b)
    The files are saved using the first-fit algorithm, in the order given. How many cards are used?
    [1 mark]
    • A55
    • B44
    • C66
    • D77
    (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

  3. 3
    The 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 N+12\frac{N+1}{2} if NN is odd and N+22\frac{N+2}{2} if NN 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

  4. 4
    The following algorithm sorts a list of nn different numbers into ascending order. Step 1: set pp equal to nn. Step 2: compare each pair of adjacent items in the first pp 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 pp by 1. Step 4: if p=1p=1, 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).