题目
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 5.
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.
After a third pass using this bubble sort, the updated list is
(c) Use a quick sort on this updated list to obtain the fully sorted list. You must make your pivots clear.
(d) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack the numbers into bins of size 5.
题目中文翻译
(a) 使用首次适应装箱算法确定上面列出的数字如何装入大小为 5 的箱子中。
列表要按降序排序。
(b) (i) 从上面列表的左端开始,使用冒泡排序对列表执行两次传递。写出第一次传递和第二次传递结束时的结果列表。
(ii) 在答案本的表格中写出这两次传递期间执行的比较次数和交换次数。
使用此冒泡排序进行第三次传递后,更新的列表为
(c) 对此更新的列表使用快速排序获得完全排序的列表。必须清楚标出枢轴。
(d) 对完全排序的列表应用首次适应递减装箱算法,将数字装入大小为 5 的箱子中。