emory-courses / dsa-java

Data Structures and Algorithms in Java
https://emory.gitbook.io/dsa-java/
42 stars 55 forks source link

[QZ3] Radix Sort Logic #77

Closed schun99 closed 4 years ago

schun99 commented 4 years ago

https://github.com/schun99/dsa-java/blob/master/src/main/java/edu/emory/cs/sort/distribution/RadixSortQuiz.java

Hi, I am not sure if I am on the right track. I created two auxiliary methods, one for counting number of elements in each bucket after the first sort and the other for sorting only certain range of given array using sub buckets. I am still working on where to put recursive method to sort within the sub buckets. Is this a valid approach?

marvinquiet commented 4 years ago

Yes, I think so!

lujiaying commented 4 years ago

Feel free to refer to https://en.wikipedia.org/wiki/Radix_sort#Most_significant_digit,_forward_recursive

lujiaying commented 4 years ago

@schun99

one for counting number of elements in each bucket after the first sort and the other for sorting only certain range of given array using sub buckets.

Yes, these two functions could be helpful. Also, to speed up you can skip certain buckets during iteration.

I am still working on where to put recursive method to sort within the sub buckets. Is this a valid approach?

Recursion sometimes might be hard to implement and debug. If recursion is not necessary (from textbook it seems to me not), please feel free to try iteration based implementation.

schun99 commented 4 years ago

Thank you so much :)