问题 填空题

在最坏情况下,堆排序需要比较的次数为 【2】

答案

参考答案:O(nlog2n)

解析:
[评析] 在最坏情况下,冒泡排序所需要的比较次数为n(n-1)/2;简单插入排序所需要的比较次数为n(n-1)/2;希尔排序所需要的比较次数为O(n^1.5);堆排序所需要的比较次数为O(nlog2n)。

多项选择题
阅读理解

阅读理解。

     A poor chimney-sweeper, who had not enough money to buy a meal, stopped one hot summer day at noon

before an eating-house, and remained regaling (享受) his nose with the smell of the victuals. The master of the

shop told him several times to go away, but the sweeper could not leave savory smell, though unable to purchase

the taste of the food. At last the cook came out of the shop, and taking hold of the sweeper, declared that, as he

had been feeding upon the smell of his victuals, he should not go away without paying half the price of a dinner.

The poor fellow said that he neither could nor would pay, and that he would ask the first person who should

pass, whether it was an unreasonable and unjust demand.

     The case was referred to a policeman, who happened to pass at that moment. He said to the sweeper:"As you

have been feasting one of your senses with the odor (气味) of this man's meat, it is but just you should make

him some recompense; therefore you shall, in your turn, regale one of his senses, which seems to be more

insatiable than your appetite. How much money do you have?"

     "I have but two pence in all the world, sir, and I must buy me some bread."

     "Never mind," answered the officer. "Take your two pence between your hands; now rattle them loudly."

     The sweeper did so, and the officer, turning to the cook, said, "Now, sir, I think he has paid you: the smell

of your victuals regaled his nostrils; the sound of his money has tickled your ears."

     This decision gave more satisfaction to the bystanders than to the cook, but it was the only payment he could

obtain.

1. The sweeper stopped one hot summer day at noon before an eating-house, because ____.

A. he wanted to regale his nose with the smell of the victuals

B. he was hungry and he wanted to have dinner

C. he was hungry but he had no enough money to buy a meal

D. he wanted to smell if the food was delicious

2. The cook's demand that the sweeper should pay half the price of a dinner was obviously ____.

 A. reasonable

B. not fair

C. logical

D. proper

3. We infer that the way that the policeman settled the problem was ____.

A. foolish

B. kind

C. clever

D. stupid

4. The passage implied, but didn't say clearly that ____.

A. it's a pity that the cook did not get what he wanted

B. the master of the shop and the cook were cool-hearted

C. the cook was cruel

D. the sweeper got what he wanted