retagged by
1,504 views
0 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

3 Answers

0 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 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 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)
Position:
Show:

Related questions

3 3 votes
3 3 answers
3.6k
3.6k views
sunil sarode asked Jan 23, 2018
3,559 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 1 vote
2 2 answers
816
816 views
Pradeep Verma asked Jul 7, 2018
816 views
Q. 16 Consider a radix sort, which is used to sort the following 3 -bit binary numbers. 100, 001, 110, 011, 010 (in the given order) Here first binary number is 100 and l...
3 3 votes
1 answers 1 answer
5.1k
5.1k views
Rohan Mundhey asked Nov 9, 2016
5,072 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 3 votes
1 answers 1 answer
4.5k
4.5k views
Sandy Sharma asked Sep 26, 2018
4,524 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)