Skip to content
CalcGospel 國際數學圖譜
返回

IAL 2022 Jan D1 Q1

A Level / Edexcel / D1

IAL 2022 Jan Paper · Question 1

题目

Problem

The numbers in the list shown above are the weights, in kilograms, of ten boxes. The boxes are to be transported in containers that will each hold a maximum weight of 40 kilograms.

179158201328412517 \quad 9 \quad 15 \quad 8 \quad 20 \quad 13 \quad 28 \quad 4 \quad 12 \quad 5

(a) Calculate a lower bound for the number of containers that will be needed to transport the boxes. You must show your working.

(2)

(b) Use the first-fit bin packing algorithm to allocate the boxes to the containers.

(3)

(c) Using the list provided, carry out a quick sort to produce a list of the weights in ascending order. You must make your pivots clear.

(3)

(d) Use the binary search algorithm to try to locate the weight of 9 in the sorted list. Clearly indicate how you choose your pivots and which part of the list is being rejected at each stage.

(3)
题目中文翻译

上面列表中的数字是十个箱子的重量(单位:千克)。箱子将用容器运输,每个容器最多可容纳 40 千克。

179158201328412517 \quad 9 \quad 15 \quad 8 \quad 20 \quad 13 \quad 28 \quad 4 \quad 12 \quad 5

(a) 计算运输箱子所需容器数量的下界。必须展示计算过程。

(b) 使用首次适应装箱算法将箱子分配给容器。

(c) 使用提供的列表,执行快速排序以产生升序的重量列表。必须清楚标出枢轴。

(d) 使用二分搜索算法尝试在排序列表中定位重量 9。清楚说明如何选择枢轴以及每个阶段拒绝列表的哪一部分。

解答

(a)

解法一

思路

展开

先求十个箱子的总重量,再除以每个容器的容量 40。所得结果必须向上取整,因为不足一个完整容器的余量仍需另用一个容器。

答题过程

展开

The total weight is

17+9+15+8+20+13+28+4+12+5=131.17+9+15+8+20+13+28+4+12+5=131.

Hence

13140=3.275.\frac{131}{40}=3.275.

Therefore the lower bound is

4 containers.\boxed{4\text{ containers}}.

(b)

解法一

思路

展开

按原顺序逐个处理重量。每次都从 Container 1 开始,放入第一个尚有足够剩余容量的容器;只有现有容器都放不下时才开启新容器。

答题过程

展开

Applying first-fit in the given order gives:

ContainerWeightsTotal
117,9,8,417,9,8,43838
215,20,515,20,54040
313,1213,122525
428282828

Thus the first-fit allocation is

C1:17,9,8,4;C2:15,20,5;C3:13,12;C4:28.\boxed{ \begin{gathered} C_1:17,9,8,4;\\ C_2:15,20,5;\\ C_3:13,12;\\ C_4:28. \end{gathered} }

(c)

解法一

思路

展开

采用 middle-right 规则选择枢轴。每次把小于枢轴的数放在左侧,大于枢轴的数放在右侧,再对尚未排好的子列表重复。下列竖线表示枢轴已经固定在最终位置。

答题过程

展开

Using middle-right pivots:

Initial pivot: 1313.

9,8,4,12,51317,15,20,289,8,4,12,5\mid13\mid17,15,20,28

Next pivots: 44 and 2020.

49,8,12,51317,1520284\mid9,8,12,5\mid13\mid17,15\mid20\mid28

Next pivots: 1212 and 1515.

49,8,51213151720284\mid9,8,5\mid12\mid13\mid15\mid17\mid20\mid28

Next pivot: 88.

4,5,8,9,12,13,15,17,20,28\boxed{4,5,8,9,12,13,15,17,20,28}

解法二

思路

展开

也可始终采用 middle-left 规则。只要每个子列表都一致地使用这一规则,并正确完成每次划分,就会得到相同的升序列表。

答题过程

展开

Using middle-left pivots:

Initial pivot: 2020.

17,9,15,8,13,4,12,5202817,9,15,8,13,4,12,5\mid20\mid28

Next pivot: 88.

4,5817,9,15,13,1220284,5\mid8\mid17,9,15,13,12\mid20\mid28

Next pivots: 44 and 1515.

4589,13,12151720284\mid5\mid8\mid9,13,12\mid15\mid17\mid20\mid28

Next pivot: 1313.

4589,1213151720284\mid5\mid8\mid9,12\mid13\mid15\mid17\mid20\mid28

Finally use pivot 99 on the remaining sublist 9,129,12:

4,5,8,9,12,13,15,17,20,28.\boxed{4,5,8,9,12,13,15,17,20,28}.

(d)

解法一

思路

展开

在升序列表中使用 middle-right 元素作枢轴。将目标值 9 与枢轴比较,每次排除不可能含有 9 的一半,直至找到 9。

答题过程

展开

The sorted list is

4,5,8,9,12,13,15,17,20,28.4,5,8,9,12,13,15,17,20,28.

For positions 11 to 1010, the middle-right position is 66, so the pivot is 1313. Since 9<139<13, reject 1313 to 2828.

For positions 11 to 55, the middle-right position is 33, so the pivot is 88. Since 9>89>8, reject 44 to 88.

For positions 44 to 55, the middle-right position is 55, so the pivot is 1212. Since 9<129<12, reject 1212.

The only remaining value is at position 44:

9 is found.\boxed{9\text{ is found}}.