Lecture 1 - Radix Sort Flashcards
What do we have to do to do better than O(nlogn) in sorting algorithms?
Use an approach that is not comparison based.
What does Radix sort do?
Exploits the structure of the numbers.
What is a disadvantage of Radix compared to any comparison-based algorithm?
It is not as versatile
What is a fact about Radix ?
That is it only faster than comparison based algorithms when used on large datasets
What does Radix Sort do?
Sorts a sequence of digits from each number in order, keeping order from previous iteration.
What is m and b in Radix Sort?
m = length of largest number in sequence
b = a factor of m, typically 2
How does changing b effect the execution of Radix Sort?
Larger b makes algorithm faster as m/b is smaller (m/b is the number of iterations), this does however increase the amount of space the algorithm uses.
How many iterations does Radix Sort use?
m/b
How many buckets does Radix sort need?
2^b buckets
What is the overall complexity of Radix Sort?
O(m/b * (n*2^b))
which is O(n), since m and b are constants
How does Radix Sort work?
There are m/b iterations. In each items are distributed into 2^b buckets, where a bucket is just a list. After buckets are concatenated and cleared ready for the next iteration.