Sunday, June 19, 2011

Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson and Ronald L. Rivest and Clifford Stein : Chapter 8

In this chapter, the authors prove a lower bound on comparison sorts (i.e. sorting algorithm that works on comparison of two elements) to be $ \Theta (n \lg n) $ and also discuss algorithms which use other operators to sort in linear time.

The authors then provide the algorithm for counting sort and proves that the algorithm is $ O(n) $. The authors also introduce a new property of the algorithm, stable, which specifies that the numbers with the same value appears in the same order in the output array as they do in the input array.

The authors then discuss radix sort which also does not rely on comparison between elements. The authors then prove following two Lemma:
Given $n$ d-digit numbers in which each digit can take on up to $k$ possible values, radix sort correctly sorts these numbers in $ \Theta (d \times (n+k)) $ time.
Given $n$ b-bit numbers and any positive integer $ r <= b $ , radix-sort correctly sorts these numbers in $ \Theta ((b/r) \times (n + 2^r) $ time. The authors then provide an algorithm of bucket sort and prove that it is $ \Theta (n) $.



No comments:

Post a Comment