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

IAL 2020 June D1 Q2

A Level / Edexcel / D1

IAL 2020 June Paper · Question 2

题目

Problem

(a) (i) Describe how to carry out the first pass of a bubble sort when it is used to sort a list of mm numbers into ascending order.

(ii) Write down the circumstances under which the bubble sort stops.

A bubble sort, starting at the left-hand end of the list, is used to sort a list of ten numbers into ascending order. After a number of passes the list reads:

____1215________D8\_\_ \quad \_\_ \quad 12 \quad 15 \quad \_\_ \quad \_\_ \quad \_\_ \quad \_\_ \quad D8

(b) Determine the maximum number of passes that could have taken place on this list. You must give a reason for your answer.

(c) Complete the bubble sort to produce a list of the numbers in ascending order. You only need to give the state of the list after each complete pass.

(d) Use the first-fit decreasing bin packing algorithm to determine how the ten numbers listed above can be packed into bins of size 4.

(Total 13 marks)

题目中文翻译

(a) (i) 描述当冒泡排序用于将 mm 个数字的列表按升序排序时,如何执行第一次传递。

(ii) 写出冒泡排序停止的情况。

从列表左端开始的冒泡排序用于将十个数字的列表按升序排序。经过多次传递后,列表为:

____1215________D8\_\_ \quad \_\_ \quad 12 \quad 15 \quad \_\_ \quad \_\_ \quad \_\_ \quad \_\_ \quad D8

(b) 确定此列表上可能已进行的最大传递次数。必须给出理由。

(c) 完成冒泡排序以产生升序的数字列表。只需给出每次完整传递结束后的列表状态。

(d) 使用首次适应递减装箱算法确定上面列出的十个数字如何装入大小为 4 的箱子中。

解答