在最坏情况下,冒泡排序的时间复杂度为 【2】 。
参考答案:n(n-1)/2或O(n(n-1)/2)
解析:[评析] 冒泡排序法是一种最简单的交换类排序方法,它是通过相邻数据元素的交换逐步将线性表变成有序。假设线性表的长度为n,则在最坏的情况下,冒泡排序需要经过n/2遍的从前往后的扫描和n/2遍的从后往前的扫描,需要的比较次数为n(n-1)/2。
在最坏情况下,冒泡排序的时间复杂度为 【2】 。
参考答案:n(n-1)/2或O(n(n-1)/2)
解析:[评析] 冒泡排序法是一种最简单的交换类排序方法,它是通过相邻数据元素的交换逐步将线性表变成有序。假设线性表的长度为n,则在最坏的情况下,冒泡排序需要经过n/2遍的从前往后的扫描和n/2遍的从后往前的扫描,需要的比较次数为n(n-1)/2。
完形填空。 | |||
Joy in the Journey | |||
( )1. A. say ( )2. A. find ( )3. A. rest ( )4. A. house ( )5. A. calmly ( )6. A. laugh ( )7. A. important ( )8. A. passers-by ( )9. A. worms ( )10. A. moved ( )11. A. contents ( )12. A. in ( )13. A. what ( )14. A. other than ( )15. A. made ( )16. A. hopelessly ( )17. A. come true ( )18. A. and ( )19. A. breaking into ( )20. A. matters | B. explain B. fill B. work B. earth B. patiently B. think B. difficult B. watchers B. rabbits B. removed B. scenes B. along B. how B. in other words B. prepared B. pleasantly B. realized B. or B. turning to B. happens | C. think C. dig C. laugh C. wall C. excitedly C. stare C. impossible C. visitors C. wolves C. broke C. pictures C. to C. where C. rather than C. produced C. surprisingly C. made C. but C. coming into C. appears | D. study D. search D. watch D. road D. impatiently D. smile D. interesting D. diggers D. flies D. pushed D. jars D. out D. which D. instead D. achieved D. successfully D. predicted D. so D. holding to D. proves |