CSE 373 Lecture 19: Wrap-Up of Sorting What's On Our Platter Today?
CSE 373 Lecture 19: Wrap-Up of Sorting What's On Our Platter Today?
From: http://www.macresource.com/mrp/ramwatch/trend.shtml
R. Rao, CSE 373 15
Shellsort
Quicksort
[Data from
textbook
Chap. 7]
Summary of Sorting
✦ Sorting choices:
➭ O(N2) – Bubblesort, Selection Sort, Insertion Sort
➭ O(Nx) – Shellsort (x = 3/2, 4/3, 7/6, 2, etc. depending on increment sequence)
➭ O(N log N) average case running time:
➧ Heapsort: uses 2 comparisons to move data (between children and
between child and parent) – may not be fast in practice (see graph)
➧ Mergesort: easy to code but uses O(N) extra space
➧ Quicksort: fastest in practice but trickier to code, O(N2) worst case
✦ Practical advice: When N is large, use Quicksort with median-of-three
pivot. For small N (< 20), the N log N sorts are slower due to extra
overhead (larger constants in big-oh notation)
➭ For N < 20, use Insertion sort
➭ E.g. In Quicksort, do insertion sort when sub-array size < 20 (instead
of partitioning) and return this sorted sub-array for further processing
To do:
Finish reading chapter 7
Start reading chapter 8