All worksheets topics

Algorithms, flow charts and bin packingEdexcel International A Level Maths: Subtopic test

10 questions, 27 marks

Edexcel International A Level Maths

Algorithms, flow charts and bin packing

Total 27 marks

Name

Class

Date

  1. 1
    An algorithm is described as follows.
    Step 1: Input a number
    NN.
    Step 2: Set
    SS equal to 0.
    Step 3: Add
    NN to SS.
    Step 4: Replace
    NN by N−3N-3.
    Step 5: If
    N>0N>0, go to Step 3.
    Step 6: Print
    SS.
    (a)
    Find the value printed when the input is N=14N=14.
    [1 mark]
    • A3939
    • B3838
    • C−1-1
    • D4040
    (b)
    For the input N=14N=14, how many times is Step 3 performed?
    [1 mark]
    • A55
    • B44
    • C66
    • D1414
    (c)
    Find the value printed when the input is N=20N=20.
    [2 marks]

    Total for question 1: 4 marks

  2. 2
    Eight files of sizes 9, 7, 11, 6, 5, 13, 12 and 10 megabytes (MB) are to be stored on memory sticks. Each memory stick can hold at most 20 MB.
    (a)
    Find the lower bound for the number of memory sticks needed.
    [1 mark]
    • A33
    • B44
    • C55
    • D88
    (b)
    The files are packed in the order given using the first-fit algorithm. How many memory sticks are used?
    [1 mark]
    • A44
    • B66
    • C55
    • D88
    (c)
    Use the first-fit decreasing algorithm to pack the files, and write down the contents of each memory stick.
    [2 marks]

    Total for question 2: 4 marks

  3. 3
    An algorithm is described as follows.
    Step 1: Input two positive integers
    AA and BB, with A>BA>B.
    Step 2: Let
    RR be the remainder when AA is divided by BB.
    Step 3: If
    R=0R=0, print BB and stop.
    Step 4: Replace
    AA by BB and BB by RR, then go to Step 2.
    (a)
    Apply the algorithm to the inputs A=252A=252 and B=105B=105, showing the values of AA, BB and RR each time Step 2 is performed.
    [3 marks]
    (b)
    (i) State what the algorithm finds.
    (ii) Apply the algorithm to
    A=89A=89 and B=55B=55. State the value printed and the number of times Step 2 is performed.
    [4 marks]

    Total for question 3: 7 marks

  4. 4
    A list of numbers is written in ascending order. The following algorithm is used to search the list for a number TT.
    Step 1: Find the middle item of the list. For a list of
    NN items, the middle item is in position N+12\frac{N+1}{2} if NN is odd and N+22\frac{N+2}{2} if NN is even.
    Step 2: If the middle item equals
    TT, stop: TT has been found.
    Step 3: If
    TT is smaller than the middle item, delete the middle item and every item after it. Otherwise delete the middle item and every item before it.
    Step 4: If no items remain, stop:
    TT is not in the list. Otherwise go to Step 1.
    (a)
    The list is 4, 9, 13, 17, 21, 26, 30, 35, 41, 47.
    (i) State the position and value of the middle item of the whole list.

    (ii) Apply the algorithm with
    T=35T=35, showing the middle item chosen each time and the items that remain.
    (iii) Apply the algorithm with
    T=10T=10 and state the outcome.
    [6 marks]
    (b)
    (i) Explain why the list must be in ascending order for the algorithm to work.
    (ii) The algorithm is applied to a list of 15 items with
    TT smaller than every item. State the position of the middle item chosen each time.
    (iii) Find the greatest number of times Step 1 is performed for a list of 20 items.
    [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).