{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# #16 Radix Sort - i is correct and positions 1 i-1 are...

This preview shows pages 1–6. Sign up to view the full content.

Radix Sort How IBM made its money, using punch card readers for census tabulation in early 1900’s. Card sorters worked on one column at a time. Sort each digit (or field) separately. Start with the least -significant digit. Must use a stable sort. RADIX-SORT (A, d) 1 for i ← 1 to d 2 do use a stable sort to sort array A on digit i

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Correctness of Radix Sort induction on number of passes base case: low-order digit is sorted correctly inductive hypothesis: show that a stable sort on digit i leaves digits 1... i sorted if 2 digits in position i are different, ordering by

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i is correct, and positions 1 . . i-1 are irrelevant – if 2 digits in position i are equal, numbers are already in the right order (by inductive hypotheis). The stable sort on digit i leaves them in the right order. • Radix sort must invoke a stable sort. Running Time of Radix Sort • use counting sort as the invoked stable sort, if the range of digits is not large • if digit range is 1. .k, then each pass takes Θ(n+k) time • there are d passes, for a total of Θ(d(n+k)) • if k = O(n), time is Θ(dn) • when d is const, we have Θ(n), linear!...
View Full Document

{[ snackBarMessage ]}

### Page1 / 6

#16 Radix Sort - i is correct and positions 1 i-1 are...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online