Comparison sorts

namebestaverageWorstMemoryStableMethodNotes
Selection sort
Bubble sort1
Insertion sort1Yes
Heapsort1No
Merge sortYes
QuicksortNo
  • Theorem (8.1) - Any comparison sort algorithm requires comparisons in the worst case.
  • Corollary (8.2) - Heapsort and merge sort are asymptotically optimal comparison sorts

Decision tree

  • The height (the longest root-to-leaf path) of a decision tree is , that is the worst-case number of comparisons in comparison sort algorithm.
  • The number of leaves is
  • The depth of any leaf is at least

Non-comparison Sorts

  • A non-comparison sort algorithm requires comparisons in the worst case.
bestaverageWorstMemoryStableNotes
Counting sortYes
Bucket sortNo
Radix Sort