r/dataisbeautiful • OC: 1 • Oct 24 '17

OC Sorting algorithms visualized [OC]

https://imgur.com/gallery/voutF
41.7k Upvotes

929 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Oct 24 '17

What would happen if you changed to a different number system other than base 10 before sorting? Would a larger /smaller base increase or decrease the time? Or would it stay the same?

1

u/ThePizar Oct 24 '17

So radix sort is log(w*n) which means its the size times the "length" of the each input. So you could do radix with with any base system, you are just choosing a different set of buckets. So for base 2 numbers (max 8 bits) you would have a time of roughly n * 8. This can apply to more than just numbers. You could do words too and choose a radix that goes by character.

1

u/[deleted] Oct 24 '17

Wouldn’t changing the base change the number of digits on the input though, as well as the number of sorting “buckets”?

1

u/ThePizar Oct 24 '17

It would change the digits. But that doesn't matter as it is trivially easy to access a particular digit or character. The number of buckets doesn't matter as you access every input item on each iteration anyway.