#16 Radix Sort

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Radix Sort in Action
Background image of page 2
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 position
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
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

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 Right Arrow Icon
Ask a homework question - tutors are online