-1

I was reading wikipedia article on Radix sort and while describing its efficiency, it says

Radix sort efficiency is O(d·n) for n keys which have d or fewer digits. Sometimes d is presented as a constant, which would make radix sort better (for sufficiently large n) than the best comparison-based sorting algorithms, which are all O(n·log(n)) number of comparisons needed. However, in general d cannot be considered a constant. In particular, under the common (but sometimes implicit) assumption that all keys are distinct, then d must be at least of the order of log(n), which gives at best (with densely packed keys) a time complexity O(n·log(n)).

Now what I don't understand is he line - assumption that all keys are distinct, then d must be at least of the order of log(n) What exactly is it trying to say?

Vincent van der Weele
  • 12,927
  • 1
  • 33
  • 61
Anoop Dixith
  • 633
  • 2
  • 8
  • 20
  • Numbering `n` keys requires `Log(n)` digits, so the keys are at least that long. –  Oct 16 '14 at 07:45

2 Answers2

2

If we consider key are distinct then we have n distinct key, now assume the biggest key is k , we know that because all the numbers are distinct so k greater or equals to n. so k have log(k) digits and it is at least log(n) so d is O(log(n))

EDIT: To be more clear about log in base 10 and 2 and Big-O read this post.

Community
  • 1
  • 1
Lrrr
  • 4,755
  • 5
  • 41
  • 63
  • @Srivatskrishnan there is no difference between log in base 10 or 2 or 16 and ... there are all the same order. constant dont effects order. – Lrrr Oct 16 '14 at 07:47
0

If all key are distinct then you can order them, and the biggest is at least n (considering positive integers only)

Then the number of digits of n is log10(n) that's why d is at least log(n)

yunandtidus
  • 3,847
  • 3
  • 29
  • 42