0% found this document useful (0 votes)
35 views

Radix Sort, CHULL

Radix sort is a sorting algorithm that sorts data by breaking it into digits. It works by sorting items into buckets based on their digit values from least to most significant digit. This sorts the data. Convex hull problems find the boundary of a set of points. Graham scan solves this in O(n log n) time by sorting points left to right and building upper and lower hulls while checking for left or right turns when adding points. While deletions during building may seem O(n^2), the total deletions are at most n, resulting in overall O(n log n) time.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Radix Sort, CHULL

Radix sort is a sorting algorithm that sorts data by breaking it into digits. It works by sorting items into buckets based on their digit values from least to most significant digit. This sorts the data. Convex hull problems find the boundary of a set of points. Graham scan solves this in O(n log n) time by sorting points left to right and building upper and lower hulls while checking for left or right turns when adding points. While deletions during building may seem O(n^2), the total deletions are at most n, resulting in overall O(n log n) time.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lecture 1.

Radix sort, CHULL Radix sort Convex hull by graham scan [Pictures] Convex hull angular graham scan [Pictures; esp. backtracking pic, and DOUBLE backtracking pic] Comparing angles [Diagrams, code fragments] Reduction from sorting to CHULL CHULL is Omega(n log n) Radix sort explanation: to sort a deck of cards from ace of clubs to king of spades, you can first sort numerically: put all the aces in one pile, all the twos in another pile, and so on. Then pick up the piles (in order) and sort into clubs, diamond, hearts and spades. When youre done, each SUIT will already be ordered A,2,3,4,,J, Q, K. ; Thats RADIX sort: if your data can be seen as broken into digits (like base 10 numbers, or like cards, where the first digit is the suit, and the second digit is the number), you can do the following: for place = least significant to most significant foreach item in list place it in a bucket according to its digit value in the current place concatenate all place-buckets, in order, into the now-empty list the list is now sorted. Application: lottery at Brown. Everyone can enter as often as they want. Need to find number of entries for each person. McBee Cards Convex hull Warmup: CCW(P, Q, R): Graham scan Find leftmost and rightmost points Sort all points left-to-right build upper hull and lower hull and glue together when done Building upper hull: o work from left to right. When you encounter a point P, add it to the upper hull. while there are at least 3 points AND the last turn in the hull is left, delete the second-to-last point Lower hull is similar, but you have to look for right turns instead.

Running time: n log n for the sorting; O(1) to insert point. After insertion, possibly O(n) deletion stepssounds like O(n^2). But actually, the TOTAL number of deletions in the entire process is no more than n, so its O(n) [total]. Combined with the sorting: O(n log n).

Angular graham scan: Nice demo at http://www.cs.princeton.edu/courses/archive/fall08/cos226/demo/ah/GrahamScan.html

You might also like