emory-courses / dsa-java

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

[QZ#3] Are we allowed to sort the input by length first? #81

Closed JonathanKimchi closed 3 years ago

JonathanKimchi commented 3 years ago

The first thing that came to my mind when I was looking to implement this Bucket Sort function was to first create a bucket sort instance where the number of buckets == the max length of any Integer passed in. From there, I would add each Integer to the bucket using their length as an index. I can sort each bucket with MSD Radix Sort without needing to worry about varying lengths, and then I can add those elements to the list once sorted. I'm just a little worried about this implementation causing memory errors, and also I didn't see anyone else doing this when researching the best way to implement MSD Radix Sort. Am I on the right track with this implementation, or am I completely off base?

Edit: Question is now irrelevant.

JonathanKimchi commented 3 years ago

This comment was deleted.