#Java: Sorting Phone Numbers with limited storage.
12 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wide vigil! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
couldn't you just sort them normally
a lot of sorts are in-place and don't use much more memory
Would you mind giving an example?
i mean, i can't think of an example that would violate the storage limit
so like, any sane sorting? built-in is timsort, for example
alternatively, just swap them in place
that'd take a bit long tho
builtin timsort would probably be the best option
just to give a point of reference, the most efficient (and sane) way to store the inputs would just be as 2,000,000 ints, which in itself would be 8 MB
so if you have better than 2n space efficiency you're set
so i think even non-in-place merge sort would work (if you manage the memory well)