retagged by
1,043 views
0 votes
0 votes

The complexity of Radix Sort is $O(wn)$, for $n$ keys which are integers of word size $w$.

Here, $w=log_2(n^k)=k\times log_2(n)$

So, the complexity is $O(wn)=O(k\times log_2(n)\times n)$

For instance if size is $n^3$ the complexity would be $O(3nlogn) = O(nlogn)$

Then why we say radix sort sorts the input in linear time?

Similar Concept used to solve : https://gateoverflow.in/3353/gate2008-it-43

retagged by

3 Answers

0 votes
0 votes
Radix sort sorts the input in linear time only in special cases not in all cases. Like input size is nearly equal to word size.
Example:- Suppose base system is 10.
0 votes
0 votes
But if you change the base '10' into base 'n' ,then each digit for every no. in the range will be 3.

So if d=constant , time complexity = 0(constant.(n+n)) : 1st 'n' is the no. of elements , 2nd 'n' is the range of each digit.

So time complexity= 0(n).
0 votes
0 votes
W = log(base 10 n^k) ... (This will give number of iterations)

 

Radix sort uses counting sort , suppose counting sort uses 10 buckets.

Therefore total time taken for each iteration = initialisation of 10 buckets + putting n elements in bucket = O(n)

Therefore total time ,

Tc = total iteration X time taken for each iteration = klog(n) X n = nklog(n) ...( Base of log is 10)

Related questions

3 votes
3 votes
3 answers
1
sunil sarode asked Jan 23, 2018
2,958 views
I am not able to get this formula (number of input * number of digit *base of number )I am not getting how base of number is important ?Thanks :)
1 votes
1 votes
2 answers
2
Pradeep Verma asked Jul 7, 2018
508 views
3 votes
3 votes
1 answer
3
Rohan Mundhey asked Nov 9, 2016
4,323 views
Consider an array of n integers ranges from 0, 1, ..., n5-1. What is the time complexity of RADIX-SORT when using base-10 representation?
3 votes
3 votes
1 answer
4
Sandy Sharma asked Sep 26, 2018
3,140 views
If Radix sort is used to sort an array of n integers which are in the range ,where d is some function of input size, the time taken would be?(A) (B)(C) (D)