Ask your own question, for FREE!
Computer Science 38 Online
OpenStudy (anonymous):

Show how to sort n integers in the range 0 to (n^3)-1 in O(n) time. hint: use radix sort

OpenStudy (anonymous):

The integers are representable as 3 digits in base n, since they're in range 0-(N^3)-1 so, we can use N buckets, where the buckets are any structure that preserves the insertion order. 1)Empty the buckets 2)Pass through the input, adding the integers to the bucket corresponding to the MSB 3)Append the contents of all buckets to a single structure X in order 4)Empty the buckets 5)Pass through X adding the integers to the bucket corresponding to the middle digit 6)repeat steps 3-5 for the LSB X now contains the sorted integers Assuming that insert is a constant time operation for the structure you choose for the buckets this sort must be O(n), as it consists of a constant number of O(n) or better steps. We know the steps are O(n) or better because they are O(1) or iterators with O(1) bodies, which are O(n)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Austinsbabygirl4life: Texas schools look funn
1 minute ago 3 Replies 0 Medals
chuu: Is it (Hunt 30-31) or (Hunt 30-1) in MLA?
6 hours ago 0 Replies 0 Medals
luvnickk: what typa music yall listen to ?
6 hours ago 15 Replies 2 Medals
GothgirlLillian: Is music considered art?
6 hours ago 2 Replies 0 Medals
luvnickk: am newwww
10 hours ago 0 Replies 0 Medals
russianmafiya: can someone help me write a love song
11 hours ago 1 Reply 0 Medals
arrivhn: ADD ME ON DISCORD ICYAFFL
11 hours ago 4 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!