为什么是插入排序比快速排序的元素的小单子更好?

问题描述:

心不是插入排序为O(n ^ 2)>快速排序O(nlogn)......所以小N,惯于之间的关系是一样的吗?

Isnt Insertion sort O(n^2) > Quick sort O(nlogn)...so for a small n, wont the relation be the same?

大O符号描述限制行为,当n很大,也被称为渐近行为。这是一个近似。 (请参阅http://en.wikipedia.org/wiki/Big_O_notation)

Big-O Notation describes the limiting behavior when n is large, also known as asymptotic behavior. This is an approximation. (See http://en.wikipedia.org/wiki/Big_O_notation)

插入排序更快对于小的n,因为快速排序先后从递归函数调用额外的开销。插入排序也比快速排序更稳定,需要的内存较少。

Insertion sort is faster for small n because Quick Sort has extra overhead from the recursive function calls. Insertion sort is also more stable than Quick sort and requires less memory.

此问题描述插入排序的另外一些好处。 (Is有过一个很好的理由来使用插入排序?)

This question describes some further benefits of insertion sort. ( Is there ever a good reason to use Insertion Sort? )