notes22

notes22 - Radix Sort - Considers binary representation of...

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

View Full Document Right Arrow Icon
Radix Sort - Considers binary representation of keys - assumes that the keys are represented in a base M number system Straight Radix Sort 5, 0, 2, 7, 3 1. Represent numbers in binary 101, 000, 010, 111, 011 2. At every iteration examine a column of bits starting from the right to the left. Examine column K and while keeping the order, sort elements based on the bit in that column. K = 0 1 0 1 000 0 0 0 010 0 1 0 => 101 1 1 1 111 0 1 1 011 K = 1 0 0 0 000 0 1 0 101 1 0 1 => 010 1 1 1 111 0 1 1 011 k = 2 0 0 0 000 0 1 0 1 010 2 0 1 0 => 011 3 1 1 1 101 5 0 1 1 111 7 Assuming that number of bits used to represent the keys is "b" then the complexity of this algorithm is b*O(n) = O(bn) / \ number of iterations steps needed at each iteration Assuming sorting int of 32 bits n b O(bn) O(nlog n)
Background image of page 1

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

View Full DocumentRight Arrow Icon
1024 32 O(32 * 1024) O(1024 * 10) <- better 1024 3 O(3 * 1024) O(1024 * 10) | better Radix sort is better than other O(n log n) algorithms only when b is small. 101 000 000 000 = 0
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 8

notes22 - Radix Sort - Considers binary representation of...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online