Why is Insertion sort better than Quick sort for small list of elements?

前端 未结 6 677
不知归路
不知归路 2020-12-01 07:47

Isn\'t Insertion sort O(n^2) > Quicksort O(n log n)...so for a small n, won\'t the relation be the same?

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 08:35

    How about binary insertion sort? You can absolutely search the position to swap by using binary search.

提交回复
热议问题