阅读以下算法说明,根据要求回答问题1~问题3。 [说明] 快速排序是一种典型的分治算法。采用快速排序对数组A[p..r]排序的3个步骤如下。 1.分解:选择一个枢轴(pivot)元素划分数组。将数组A[p..r]划分为两个子数组(可能为空)A[p..q-1]和A[q+1..r],使得A[q]大于等于A[p..q-1]中的每个元素,小于A[q+1..r]中的每个元素。q的值在划分过程中计算。 2.递归求解:通过递归的调用快速排序,对子数组A[p..q-1]和A[q+1..r]分别排序。 3.合并:快速排序在原地排序,故无需合并操作。 [问题2] (1)假设要排序包含n个元素的数组,请给出在各种不同的划分情况下,快速排序的时间复杂度(用 O记号)。最佳情况为 (4) ,平均情况为 (5) ,最坏情况为 (6) 。 (2)假设要排序的n个元素都具有相同值时,快速排序的运行时间复杂度属于哪种情况 (7) 。 (最佳、平均、最坏)
MEMOTo: PeterFrom: TomThe publicity leaflets for the new model will not be back from the printers until Friday 11 July.
A. We might have the leaflets before 11 July.
B. We won’t have the leaflets before 11 July.
C. We are sure to have the leaflets before 11 July.
We are carrying out market research in the north and the Midlands from 22nd-26th.
A. We have done the research in the north and the Midlands.
B. We haven’t done the research in the north and the Midlands yet.
C. We have decided not to do research in the north and the Midlands.