emory-courses / dsa-java

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

[QZ#3 Lambda Question] #65

Closed TFloyd1989 closed 4 years ago

TFloyd1989 commented 4 years ago

Where does the 'key' in the lambda function in LSD sort come from?(key -> (key / div) % 10). I don't see it initialized anywhere, I was wondering how its value is determined?

TFloyd1989 commented 4 years ago

I actually took some time to understand it and I have a good grasp of it. Instead of the previous question, I now wonder what other sort we can use instead of bucketsort?

marvinquiet commented 4 years ago

For MSD, you can use the bucketsort. I still feel it reasonable to track the beginIndex and endIndex.

For how to track, you can actually get the size of each bucket by using buckets.get(digit).size(), then a recursive way would be fine

TFloyd1989 commented 4 years ago

Thank you, however, what does digit represent? The digit of the bucket such as 0?

TFloyd1989 commented 4 years ago

Is there also a way to find the total number of buckets?

marvinquiet commented 4 years ago

Yes, digit represents 0-9.

Yes, there is a way because buckets is just a list referring to line 31 here. Similarly, the way to get the number of buckets is the way of getting the length of the list. Does it sound reasonable?

TFloyd1989 commented 4 years ago

I think this makes sense