day 2 1/14/98
A lower bound on the time complexity of sorting algorithms given only the use of a compare primitive, compare(a,b), which returns (a < b) is W(log2n!) » W(nlog2n) . You can see this by noting that there are n! possible outcomes to sorting n elements which implies that log2n! choices must be made.
Insert each element into a (balanced) binary tree, then traverse the tree in order to find the sort
Place all the elements into a heap and pull them out of the heap in order
Split the elements into 2 equal size subsequences, sort each subsequence, then merge the two sorted subsequences.
let Sort(P) =
m = Median(P)
return Sort({Pi:Pi < m}) :m: Sort({Pi:Pi > m})
This differs from merge sort, becuase the work at a particular level occurs before recursing so only a concatentation is necessary on return.
Otherwise known as quicksort.
let QSort(P) =
m = Random(P)
return Sort({Pi:Pi < m}) :m: Sort({Pi:Pi > m})
Sign(Det([
|
|
| |||
|
|
| |||
|
|
| |||
Graham Scan( P1,..,Pn ) =
Heuristically, this algorithm winds counterclockwise around the points, unwinding to remove points not in the convex hull every time it discovers (by LR_test) that a point is not in the convex hull. The time complexity of this algorithm is dominated by the sort, O(nlogn) .