试题与答案

假设线性表的长度为n,则在最坏情况下,冒泡排序法的时间复杂度是______。A.lo

题型:单项选择题

题目:

假设线性表的长度为n,则在最坏情况下,冒泡排序法的时间复杂度是______。

A.log2n

B.nlog2n

C.n(n-1)

D.n(n-1)/2

答案:

参考答案:D

解析:假设线性表的长度为n,则在最坏的情况下,冒泡排序需要经过n/2遍的从前往后的扫描和n/2遍的从后往前的扫描.需要的比较次数为n(n-1)/2。

试题推荐
题型:听力题

缺词填空(共10空;每空l分,计l0分)

根据短文内容和首字母提示,在下文空格处填入适当的词使短文完整。(每空一词)

Autumn is a season of both harvest and planting. Similarly, when we step into college, we harvest the hard work from high school, and at the same time, we plant hope for our f___小题1:___

Farmers take care of the plants and irrigate(灌溉) them with much e__小题2:___. We college students should also make full use of our time and work hard so t__小题3:___we can have a good harvest when we graduate.

Yangzhou University is a good place to plant our dreams. A___小题4:__ a student of Yangzhou university, I always feel proud and lucky to have a c__小题5:___ to study here. It is a college w_小题6:_ long history. People around me always c__小题7:__ for me, encourage me, and give me love.

Every year in autumn, my college w__小题8:___ new students and guides them to realize their dreams. They’ll spend the best time of their lives to look for the v__小题9:___of life here. I believe that Yangzhou University students will make great achievements someday, because our college is like a__小题10:___ and we will harvest what we plant here.

查看答案
微信公众账号搜索答案