Overview of Sorting

6
Overview of Sorting by Ron Peterson

description

Overview of Sorting. by Ron Peterson. Variety of Algorithms. There are a lot of different approaches to sorting, not just different programs that use similar methods. Donald Knuth’s, The Art of Computer Programming , Vol. 3, documents dozens of algorithmic methods for sorting. - PowerPoint PPT Presentation

Transcript of Overview of Sorting

Page 1: Overview of Sorting

Overview of Sorting

by Ron Peterson

Page 2: Overview of Sorting

Variety of Algorithms

• There are a lot of different approaches to sorting, not just different programs that use similar methods.

• Donald Knuth’s, The Art of Computer Programming, Vol. 3, documents dozens of algorithmic methods for sorting.

• Examples: bubble, insertion, selection, Shell, merge, heap, quick, & radix are all prefixes of names of sorts.

Page 3: Overview of Sorting

More Sort Names

• Bubble sort · Cocktail sort · Odd-even sort · Comb sort · Gnome sort · Quicksort · Selection sort · Heapsort · Smoothsort · Cartesian tree sort · Tournament sort · Cycle sort · Insertion sort · Shell sort · Tree sort · Library sort · Patience sorting · Monkey-puzzle sort · Merge sort · Polyphase merge sort · Strand sort · American flag sort · Bead sort · Bucket sort · Burstsort · Counting sort · Pigeonhole sort · Proxmap sort · Radix sort · Flashsort · Bitonic sorter · Batcher odd-even mergesort · Timsort · Introsort · Spreadsort · UnShuffle sort · JSort · Spaghetti sort · Pancake sort

Page 4: Overview of Sorting

Categories by Efficiency

• Simple sorts – O(N^2)– Bubble, selection, insertion sorts

• Intermediate sorts– Shell – O(N*log^2 N)

• Efficient sorts – O(N*log N)– Quicksort, merge sort, Heap sort

• Specialty sorts– Radix – O(C) (* # of digits per value)

Page 5: Overview of Sorting

What you should know

• For each sort discussed:– The name– Its efficiency

• Average, best, and worst

– How it works

• Study the individual sorts in the book and look at the videos on the syllabus link

Page 6: Overview of Sorting

2 more topics

• Stable sorts:– Used for multi-key sorts like First/Last name– Does not change order within key group– Merge sort is typically a “stable” sort

• STL sort algorithms:– Same interface for each (begin-it, end-it, [opl])– Main approaches:

• sort(..); stable_sort(..); make_heap(..), sort_heap(..); {plus a few tools to build others}