D1: Algorithms (sorting, searching, bin packing) – Edexcel IAL Decision Mathematics (WDM1)
12 questions · Clear filters
Question text
1.
24 16 34 21 38 12 31 5 9 14 23
The eleven numbers above are to be packed into bins of size 60
(a) Calculate a lower bound for the minimum number of bins required.
(2)
(b) Use the first‑fit bin packing algorithm to pack the numbers into bins of size 60
(3)
(c) Use bubble sort to sort the list of numbers into descending order, showing the result
after each pass.
(4)
(d) Use the first‑fit decreasing bin packing algorithm to pack the numbers into bins of
size 60
(2)
(Total for Question 1 is 11 marks)
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)
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)
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)
Question text
3.
28 12 15 24 20 13 16
7 11
The nine numbers above are to be packed into bins of size n, where n is an
unknown integer.
When the first‑fit bin packing algorithm is used, the numbers are packed as follows
Bin 1
28
12
7
Bin 2
15
24
11
Bin 3
20
13
16
(a) Determine the possible values of n
(3)
When the first‑fit decreasing bin packing algorithm is used, four bins are required.
(b) Determine the value of n, justifying your answer.
(2)
(Total for Question 3 is 5 marks)
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)
Question text
3:
(i) A list of twelve numbers is to be sorted into ascending order.
28 18 50 27 48 8 25 12 56 31 33 42
(a) Use a quick sort to obtain the sorted list. You should show the result of each pass
and identify your pivots clearly.
(4)
(b) Show how the binary search algorithm is used to try to locate the number 40 in
the list. You must clearly indicate your choice of pivots and which part of the list
you are rejecting.
(3)
(ii) A different list of nine distinct integers is to be sorted into descending order.
23
20
32
15
8
19
6
22
x
The list is sorted using bubble sort. The first three passes are
23
20
32
15
19
8
22
6
x
23
32
20
19
15
22
8
6
x
32
23
20
19
22
15
8
6
x
Determine the range of possible values of x
(2)
(Total for Question 3 is 9 marks)
Question text
1.
5.2
4.7
6.5
4.5
3.1
5.1
1.8
2.9
3.4
3.8
1.2
(a) Use the first‑fit bin packing algorithm to determine how the eleven numbers listed
above can be packed into bins of size 14
(3)
(b) The list of 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)
(c) Apply the first‑fit decreasing bin packing algorithm to the sorted list to pack the
numbers into bins of size 14
(3)
(d) Explain why the number of bins used in part (c) is optimal.
(1)
(e) Use the binary search algorithm to try to locate 3.0 in the list of numbers.
Clearly indicate how you choose your pivots and which part of the list is rejected at
each stage.
(3)
(Total for Question 1 is 14 marks)
Question text
2. A list of eleven numbers is to be sorted into descending order.
After one pass, the quick sort algorithm produces the following list
17 33 14 25 23 28 21 13 9 6 10
(a) State, with a reason, which number was used as a pivot for the first pass.
(1)
(b) Starting at the left-hand end of the above list, obtain the fully sorted list using a
bubble sort. You need to write down only the list that results at the end of each pass.
(3)
(c) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack
the numbers into bins of size 85
(2)
(Total for Question 2 is 6 marks)
Question text
3. In this question, the function INT(X ) is the largest integer less than or equal to X.
For example,
INT(5.7) = 5
INT(8) = 8
INT(–2.3) = –3
Consider the following algorithm.
Step 1 Input N
Step 2
Calculate A = N ÷ 10
Step 3
Let B = INT(A)
Step 4
Calculate C = B × 10
Step 5
Calculate D = N – C
ptep 6&&lutput a
Step 7 Replace N by B
Step 8 If N = 0 then STOP, otherwise go back to Step 2
(a) Complete the table in the answer book, using N = 4217, to show the results obtained
at each step of the algorithm.
(4)
(b) Explain how the output values of the algorithm relate to the original input N,
where N is any positive integer.
(2)
(Total for Question 3 is 6 marks)
Question text
3.
You may not need to use all the rows in this table.
It may not be necessary to complete all boxes in each row.
N
A
B
C
D
Outputs:
Question 3 continued
(Total for Question 3 is 6 marks)
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)