Algorithms

Spring 2013
course
navigation

Feb 12

Discuss homework answers .
Start chapter 4 material: sorting.
Why?

heaps & heapsort

wikipedia: binary heap
Very cool datastructure. Common implementation of "priority queue"
There are a number of variations.
heapsort : given N things, put 'em in a heap, then pop_min repeatedly. Gives O(n log(n)).
The text describes this as a "datastructure" approach to finding the algorithm. Really ... it's a classic cute trick; I'm not sure how this one generalizes to finding algorithms for other problems.

merge sort

wikipedia: merge sort
The general approach here is called "divide-and-conquer", and is applicable to many problems. Typically gives a log2(n) (rather than n) improvement.
Another O(n log(n))
Disadvantage: may need extra space.

quicksort

wikipedia: quicksort
Another divide-and-conquer, but using "pivots", often chosen "randomly".
This is in practice one of the fastest sorts (for reasons that aren't obvious) and is a common choice if little is known in advance about the things to sort.
In class:
http://cs.marlboro.edu/ courses/ spring2013/algorithms/ notes/ Feb_12
last modified Tuesday February 12 2013 11:13 am EST