D1: Algorithms (sorting, searching, bin packing) – Edexcel IAL Decision Mathematics (WDM1)

10 questions

0 / 0Answer a question to start your score.
New quizSaved 0

Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.

Advertisement
1
WDM1 D1 · Jun 2026 · Section 1, Question 2May/June 2026D15 marks
Loading question…
Question text

2.
START
INPUT A
A
Let B
10
A
1
Let C
( B )
B
2
Let D = B – C
Is
Yes
OUTPUT C
–0.1 < D < 0.1?
No
STOP
Let B = C
Figure 1
The flowchart for an algorithm is shown above.
The input for the algorithm is a positive number.
(a) Apply the algorithm using A = 1250. You must complete the table in the answer
book, showing the results at each step of the algorithm. Give your values to
3 decimal places where necessary.
(4)
(b) State how the output, C, relates to the input, A
(1)
(Total for Question 2 is 5 marks)

2
WDM1 D1 · Jun 2022 · Section 1, Question 1May/June 2022D19 marks
Loading question…
Question text

1.
175
135
210
105
100
150
60
20
70
125
The numbers in the list above represent the weights, in kilograms, of ten crates. The
crates are to be transported in trucks that can each hold a maximum total crate weight
of 300 kg.
(a) Calculate a lower bound for the number of trucks that will be needed to transport
the crates.
(2)
(b) Using the list provided, carry out a bubble sort to produce a list of the weights in
descending order. You need only give the state of the list after each pass.
(4)
(c) Use the first‑fit decreasing bin packing algorithm to allocate the crates to the trucks.
(3)
(Total for Question 1 is 9 marks)

3
WDM1 D1 · Jun 2026 · Section 1, Question 4May/June 2026D110 marks
Loading question…
Question text

4.
A
B
C
D
E
F
G
H
A
–
34
42
29
36
43
28
6x + 7
B
34
–
27
40
28
51
43
8x – 2
C
42
27
–
31
41
37
32
46
D
29
40
31
–
25
34
43
39
E
36
28
41
25
–
30
38
52
F
43
51
37
34
30
–
31
48
G
28
43
32
43
38
31
–
34
H
6x + 7
8x – 2
46
39
52
48
34
–
The table shows the shortest distances, in miles, between eight towns, A, B, C, D, E, F,
G and H, where x is an unknown positive integer.
Raphael wants to visit all eight towns and needs to find a route that minimises the total
distance travelled returning to the starting point.
An initial upper bound for the length of Raphael’s route, obtained using the nearest
neighbour algorithm starting at H, is 256 miles. This nearest neighbour route starts with
arc HG.
(a) Use the nearest neighbour algorithm starting at A, to obtain an expression for a
second upper bound for the length of Raphael’s route. You must state the route and
its length in terms of x.
(3)
Given that the upper bound obtained by starting at A is better than the initial
upper bound,
(b) use the answer to part (a) to calculate the value of x
(3)
(c) By deleting A and all its arcs, obtain a lower bound for the length of
Raphael’s route.
(3)
(d) Write down the smallest interval that must contain the length of Raphael’s route.
(1)
(Total for Question 4 is 10 marks)

Advertisement
4
WDM1 D1 · Jan 2023 · Section 2, Question 3January 2023D113 marks
Loading question…
Question text

3.
1.8 1.4 2.6 1.6 2.8 0.9 3.1 0.8 1.2 2.4 0.6
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above
can be packed into bins of size 5
(3)
The list is to be sorted into descending order.
(b) (i) Perform one pass of a bubble sort, starting at the left-hand end of the list. You
must write down the list that results at the end of the first pass.
(ii) Write down the number of comparisons and the number of swaps performed
during the first pass.
(3)
After a second pass using this bubble sort, the updated list is
2.6 1.8 2.8 1.6 3.1 1.4 1.2 2.4 0.9 0.8 0.6
(c) Use a quick sort on this updated list to obtain the fully sorted list in descending
order. You must make your pivots clear.
(4)
(d) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack
the numbers into bins of size 5
(3)
(Total for Question 3 is 13 marks)

5
WDM1 D1 · Jan 2021 · Question 2January 2021D166 marks
Loading question…
Question text

2.
A restaurant sells two sizes of pizza, small and large. The restaurant owner knows that, each
evening, she needs to make
•
at least 85 pizzas in total
•
at least twice as many large pizzas as small pizzas
In addition, at most 80% of the pizzas must be large.
Each small pizza costs £2 to make and each large pizza costs £3 to make.
The restaurant owner wants to minimise her costs.
Let x represent the number of small pizzas made each evening and let y represent the number of
large pizzas made each evening.
Formulate the information above as a linear programming problem. State the objective and list the
constraints as simplified inequalities with integer coefficients. You should not attempt to solve the
problem.
(Total 5 marks)
3.
2.6 0.8 2.1 1.2 0.9 1.7 2.3 0.3 1.8 2.7
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be
packed into bins of size 5
(3)
The list is to be sorted into descending order.
(b) (i) Starting at the left-hand end of the above list, perform two passes through the list using a
bubble sort. Write down the lists that result at the end of the first pass and the second pass.
(ii) Write down, in the table in the answer book, the number of comparisons and the number
of swaps performed during each of these two passes.
(4)
After a third pass using this bubble sort, the updated list is
2.6 2.1 1.7 2.3 1.2 1.8 2.7 0.9 0.8 0.3
(c) Use a quick sort on this updated list to obtain the fully sorted list. You must make your
pivots clear.
(3)
(d) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack the numbers
into bins of size 5
(3)
(Total 13 marks)
4.
(a) Explain the difference between the classical and the practical travelling salesperson problems.
(2)
The table below shows the distances, in km, between seven museums, A, B, C, D, E, F and G.
A
B
C
D
E
F
G
A
–
25
31
28
35
30
32
B
25
–
34
24
27
32
39
C
31
34
–
40
35
27
29
D
28
24
40
–
37
35
36
E
35
27
35
37
–
28
31
F
30
32
27
35
28
–
33
G
32
39
29
36
31
33
–
Fran must visit each museum. She will start and finish at A and wishes to minimise the total
distance travelled.
(b) Starting at A, use the nearest neighbour algorithm to obtain an upper bound for the length of
Fran’s route. Make your method clear.
(2)
Starting at D, a second upper bound of 203 km was found.
(c) State whether this is a better upper bound than the answer to (b), giving a reason for your
answer.
(1)
A reduced network is formed by deleting G and all the arcs that are directly joined to G.
(d) (i) Use Prim’s algorithm, starting at A, to construct a minimum spanning tree for the reduced
network. You must clearly state the order in which you select the arcs of your tree.
(ii) Hence calculate a lower bound for the length of Fran’s route.
(4)
By deleting A, a second lower bound was found to be 188 km.
(e) State whether this is a better lower bound than the answer to (d)(ii), giving a reason for
your answer.
(1)
(f) Using only the results from (c) and (e), write down the smallest interval that you can be
confident contains the length of Fran’s optimal route.
(2)
(Total 12 marks)
5.
B
D
G
22
12
13
32
10
7
A
9
22
E
15
J
16
C
5
28
5
F
22
29
H
K
6
Figure 1
[The total weight of the network is 253]
Figure 1 represents a network of roads between 10 cities, A, B, C, D, E, F, G, H, J and K.
The number on each edge represents the length, in miles, of the corresponding road.
One day, Mabintou wishes to travel from A to H. She wishes to minimise the distance she travels.
(a) Use Dijkstra’s algorithm to find the shortest path from A to H. State your path and its length.
(6)
On another day, Mabintou wishes to travel from F to K via A.
(b) Find a route of minimum length from F to K via A and state its length.
(2)
The roads between the cities need to be inspected. James must travel along each road at least once.
He wishes to minimise the length of his inspection route. James will start his inspection route at A
and finish at J.
(c) By considering the pai

6
WDM1 D1 · Jun 2025 · Section 1, Question 1May/June 2025D14 marks
Loading question…
Question text

1: The list of numbers shown below represents the masses, in kg, of nine items that are to
be moved from one factory to another.
180
300
250
410
240
120
230
310
190
The items will all be moved, by van, at the same time.
Each van can carry at most 600 kg.
(a) Calculate a lower bound for the number of vans required.
(2)
(b) Use the first‑fit bin‑packing algorithm to allocate the items to vans.
(2)
(Total for Question 1 is 4 marks)

7
WDM1 D1 · Jan 2025 · Section 1, Question 3January 2025D15 marks
Loading question…
Question text

3.
Start
Input a, b
Let c = ab
a
Let d = a
b
Let e = INT(d)
Let f = be
Let g = a – f
Yes
c
Is
Let h = c
g = 0?
b
No
Output h
Let a = b
Stop
Let b = g
Figure 2
Figure 2 shows the flowchart for an algorithm.
The input for the algorithm is two positive integers.
The function INT(X) is the largest integer less than or equal to X
(a) Complete the table in the answer book, with a = 1980 and b = 462, showing the
results at each step of the algorithm.
(4)
(b) Explain how the output, h, relates to the inputs, a and b
(1)
(Total for Question 3 is 5 marks)

8
WDM1 D1 · Jan 2023 · Section 2, Question 1January 2023D17 marks
Loading question…
Question text

1.
A
B
C
D
E
F
G
A
–
43
52
47
59
53
55
B
43
–
59
45
46
52
47
C
52
59
–
51
50
55
51
D
47
45
51
–
52
49
55
E
59
46
50
52
–
57
48
F
53
52
55
49
57
–
55
G
55
47
51
55
48
55
–
The table above shows the least distances, in metres, between seven classrooms, A, B,
C, D, E, F and G. A teacher needs to visit each classroom, starting and finishing at A,
and wishes to minimise the total distance travelled.
(a) Show that there are two nearest neighbour routes that start from A. State these routes
and their corresponding lengths.
(3)
(b) Starting by deleting A, and all of its arcs, find a lower bound for the length of the
teacher’s route.
(3)
(c) Use your results to write down the smallest interval which you can be confident
contains the optimal length of the teacher’s route.
(1)
(Total for Question 1 is 7 marks)

Advertisement
9
WDM1 D1 · Jan 2024 · Section 1, Question 6January 2024D19 marks
Loading question…
Question text

6. The twelve numbers in the list below are to be packed into bins of size n, where n is a
positive integer.
28
31
5
25
16
35
18
22
11
27
15
13
When the first‑fit bin packing algorithm is applied to the list, the following allocation
is obtained.
Bin 1:
28
31
5
Bin 2:
25
16
18
11
Bin 3:
35
22
15
Bin 4:
27
13
(a) Based on the packing shown above, determine the possible values of n. You must
give reasons for your answer.
(3)
(b) The original list of twelve numbers is to be sorted into ascending order. Use a quick
sort to obtain the sorted list. You should show the result of each pass and identify
your pivots clearly.
(4)
When the first‑fit decreasing bin packing algorithm is applied to the list, the following
allocation is obtained.
Bin 1:
35
31
5
Bin 2:
28
27
16
Bin 3:
25
22
18
Bin 4:
15
13
11
(c) Determine the value of n. You must give a reason for your answer.
(2)
(Total for Question 6 is 9 marks)

10
WDM1 D1 · Jun 2026 · Section 2, Question 2May/June 2026D15 marks
Loading question…
Question text

2.
You may not need to use all the rows in this table.
Is
–0.1 < D < 0.1
A
B
C
D
?
Question 2 continued
Is
–0.1 < D < 0.1
A
B
C
D
?
Output
(Total for Question 2 is 5 marks)

Advertisement