Radix Sort and Insertion Sort
Radix Sort and Insertion Sort
sort algorithms.
(2 marks)
SOLUTION:
Time Complexity of Radix Sort Algorithm:
The time complexity of radix sort is given by the formula,T(n) = O(d*(n+b)), where
d is the number of digits in the given list, n is the number of elements in the
list, and b is the base or bucket size used, which is normally base 10 for decimal
representation.
Best Case - The best case occurs when all elements have the same number of digits.
The best case time complexity is O(d(n+b)). If b = O(n), then time complexity is
O(dn).
Worst Case - The worst case in radix sort occurs when all elements have the same
number of digits except one element which has a significantly large number of
digits. If the number of digits in the largest element is equal to n, then the
runtime becomes O(n2). The worst case running time of Counting sort is O(n+b). If
b=O(n), then the worst case running time is O(n). Here,the countingSort function is
called for d times, where d = [logb(mx)+1]. Total worst case complexity of radix
sort is O(logb(mx)(n+b)).