Summary

DRAFT

Algorithm Best Average Worst Memory Stable Notes

Bubble sort

Θ(N)\Theta\left(N\right)

Θ(N2)\Theta\left(N^2\right)

Θ(N2)\Theta\left(N^2\right)

Θ(1)\Theta(1)

Yes

Selection sort

Θ(N2)\Theta \left(N^2\right)

Θ(N2)\Theta \left(N^2\right)

Θ(N2)\Theta \left(N^2\right)

Θ(1)\Theta(1)

No

Stable with Θ(N)\Theta(N) extra memory.

Insertion sort

Θ(N)\Theta\left(N\right)

Θ(N2)\Theta\left(N^2\right)

Θ(N2)\Theta\left(N^2\right)

Θ(1)\Theta(1)

Yes

Θ(N)\Theta(N) if almost sorted.

Heapsort

Θ(NlogN)\Theta(N \log N)

Θ(NlogN)\Theta(N \log N)

Θ(NlogN)\Theta(N \log N)

Θ(1)\Theta(1)

No

Merge sort

Θ(NlogN)\Theta(N \log N)

Θ(NlogN)\Theta(N \log N)

Θ(NlogN)\Theta(N \log N)

Θ(N)\Theta(N)

Yes

Good cache performance

Random Quicksort

Θ(NlogN)\Theta(N \log N)

Θ(NlogN)\Theta(N \log N)

Θ(N2)\Theta \left(N^2\right)

Θ(logN)\Theta(\log N) for the stack frames, Θ(1)\Theta(1) otherwise

No

Fastest sort

results matching ""

    No results matching ""