day 2 1/14/98

1.  Sorting vs. Convex hull

1.1  sorting algorithms

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.

1.1.1 Insertion sort

Insert each element into a (balanced) binary tree, then traverse the tree in order to find the sort

1.1.2 heap sort

Place all the elements into a heap and pull them out of the heap in order

1.1.3 merge sort

Split the elements into 2 equal size subsequences, sort each subsequence, then merge the two sorted subsequences.

1.1.4 median sort

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})

1.2  Convex hull algorithms

1.2.1 The primitive operations of convex hull algorithms

1.2.2 definitions

1.2.3 Convex hull heap sort analog = Graham scan

Graham Scan( P1,..,Pn ) =

  1. pick P = Pi with minimum y value.
  2. compute qj = slope(P,Pj)"j ¹ i
  3. sort slopes Sort(q1,...,qn-1)
  4. push P1,P2 onto stack C
  5. while size(C) ³ 2 let C1 = Pop(C),C2 = Pop(C) if LR_test(Line_segment( C1,C2 ), Pi )=R then Pop(C) else Push(Pi);i: = i+1
  6. push P and return C

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) .


File translated from TEX by TTH, version 1.30.