9FM0 Topic Test - D1 - 1 - Algorithms PDF
9FM0 Topic Test - D1 - 1 - Algorithms PDF
Pearson aspires to be the world’s leading learning company. Our aim is to help everyone progress in their lives
through education. We believe in every kind of learning, for all kinds of people, wherever they are in the
world. We’ve been involved in education for over 150 years, and by working across 70 countries, in 100
languages, we have built an international reputation for our commitment to high standards and raising
achievement through innovation in education. Find out more about how we can help you and your students
at: www.pearson.com/uk
• This topic test is comprised from legacy past paper questions (prior to
2019) and BRAND NEW exam style questions. The new questions are:
5(b)
6(b)
7(d)
8(b)
• The exam questions have been selected for the topic of Algorithms with
the intention of being used in isolation, however some inherent overlap
between topics may occur.
• The questions within this topic test have been ordered in terms of
difficulty, from ‘easiest’ to ‘hardest’.
Start
Read a, b
Let c = a b to 2 d.p.
Let e = db
Let f = a − e
Yes Write
Is Stop
f = 0? “answer is” b
No
Let a = b
Let b = f
(a) Given that a = 645 and b = 255, complete the table in the answer booklet to show the results
obtained at each step when the algorithm is applied.
(7)
(b) Explain how your solution to part (a) would be different if you had been given that a = 255 and
b = 645.
(3)
Figure 1
Figure 1 describes an algorithm in the form of a flow chart, where a is a positive integer.
List P, which is referred to in the flow chart, comprises the prime numbers 2, 3, 5, 7, 11, 13, 17, ...
(a) Starting with a = 90, implement this algorithm. Show your working in the table in the answer
book.
(7)
(b) Explain the significance of the output list.
(2)
(c) Write down the final value of c for any initial value of a.
(1)
(Total 10 marks)
___________________________________________________________________________
(Total 9 marks)
___________________________________________________________________________
(a) The list of numbers above is to be sorted into descending order. Perform a bubble sort to obtain
the sorted list, giving the state of the list after each completed pass.
(4)
The bubble sort algorithm has quadratic order.
(b) Given that it takes a computer 0.3 seconds to sort a list of 2000 numbers using the bubble sort,
estimate the time needed to sort a list of 120 000 numbers.
(2)
(Total 6 marks)
___________________________________________________________________________
6.
Ali 74
Bobby 28
Eun-Jung 63
Katie 54
Marciana 54
Peter 49
Rory 37
Sophie 68
The table shows the marks obtained by students in a test. The students are listed in alphabetical order.
(a) Carry out a quick sort to produce a list of students in descending order of marks. You should show
the result of each pass and identify your pivots clearly.
(5)
For a list of n numbers, the quick sort algorithm has, on average, order nlogn.
(b) Given that it takes 1.64 seconds to run the algorithm when n = 300, calculate approximately how
long it will take to run the algorithm when n = 10800, giving your answer to the nearest tenth of a
second and making your method clear.
(2)
(Total 7 marks)
___________________________________________________________________________
The numbers in the list represent the lengths in minutes of nine radio programmes. They are to be
recorded onto tapes which each store up to 100 minutes of programmes.
(a) Obtain a lower bound for the number of tapes needed to store the nine programmes.
(2)
(b) Use the first-fit bin packing algorithm to fit the programmes onto the tapes.
(3)
(c) Use the first-fit decreasing bin packing algorithm to fit the programmes onto the tapes.
(3)
(d) The first-fit bin packing algorithm has quadratic order. Given that it takes a computer 0.5 seconds
to pack a list of 5000 numbers using first-fit bin packing, estimate the time taken to pack a list of
1 200 000 numbers.
(2)
(Total 10 marks)
___________________________________________________________________________
(a) Use the bubble sort algorithm to sort the list of numbers above into descending order showing the
rearranged order after each pass.
(5)
The bubble sort algorithm is to be used to sort a list of n numbers. The number of comparisons is used
to measure the order of the bubble sort algorithm.
(b) By considering the worst case, determine the order of the bubble sort algorithm in terms of n. You
must make your method and working clear.
(3)
Jessica wants to record a number of television programmes onto video tapes. Each tape is 2 hours
long. The lengths, in minutes, of the programmes she wishes to record are:
55, 45, 20, 30, 30, 40, 20, 90, 25, 50, 35 and 35.
(c) Find the total length of programmes to be recorded and hence determine a lower bound for the
number of tapes required.
(2)
(d) Use the first fit decreasing algorithm to fit the programmes onto her 2-hour tapes.
(3)
Jessica’s friend Amy says she can fit all the programmes onto 4 tapes.
(e) Show how this is possible.
(2)
(Total 15 marks)
___________________________________________________________________________
(a) The list of numbers above is to be sorted into descending order. Perform a Quick Sort to obtain
the sorted list, giving the state of the list after each pass, indicating the pivot elements.
(5)
The numbers in the list represent the lengths, in mm, of some pieces of wood. The wood is sold in one
metre lengths.
(b) Use the first-fit decreasing bin packing algorithm to determine how these pieces could be cut
from the minimum number of one metre lengths. (You should ignore wastage due to cutting.)
(4)
(c) Determine whether your solution to part (b) is optimal. Give a reason for your answer.
(2)
(Total 11 marks)
___________________________________________________________________________
10. Explain what is meant by a planar graph.
(2)
(Total 2 marks)
___________________________________________________________________________
11. Figure 4
Use the planarity algorithm to show that the graph in Figure 4 is planar.
(4)
(Total 4 marks)
___________________________________________________________________________
A B, D, E, F
B C, D, E
C D, E
D E
E F
F B
(a) On the diagram in the answer book draw straight lines to show which components need to
be connected.
(1)
(b) Starting with the Hamiltonian cycle ABCDEFA, use the planarity algorithm to determine whether
it is possible to build this product on a circuit board.
(4)
(Total 5 marks)