插入排序比冒泡排序好吗? [英] Insertion sort better than Bubble sort?

查看:107
本文介绍了插入排序比冒泡排序好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为考试做修订。

在相同的平均复杂度O()下,我想知道在什么条件下插入排序会比冒泡排序更好。 N ^ 2)。

Would like to know under what condition will Insertion sort performs better than bubble sort given same average case complexity of O(N^2).

我确实找到了一些相关文章,但我听不懂。

I did found some related articles, but I can't understand them.

有人介意以简单的方式解释它吗?

Would anyone mind explaining it in a simple way?

推荐答案

bubbleort的优点在于可以检测到已经排序的列表:

The advantage of bubblesort is in the speed of detecting an already sorted list:


BubbleSort最佳情况: O(n)

但是,即使在这种情况下,插入排序也具有更好的/相同的性能。

However, even in this case insertion sort got better/same performance.

Bubblesort或多或少仅对理解和/或教授排序算法的机制,但由于它们的复杂性,这些天在编程中找不到合适的用法

Bubblesort is, more or less, only good for understanding and/or teaching the mechanism of sortalgorithm, but wont find a proper usage in programming these days, because its complexity


O (n²)

表示效率降低在包含少量元素的列表上大大简化了操作。

means that its efficiency decreases dramatically on lists of more than a small number of elements.

这篇关于插入排序比冒泡排序好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆