#Java: Sorting Phone Numbers with limited storage.

12 messages · Page 1 of 1 (latest)

earnest locustBOT
#

This post has been reserved for your question.

Hey @wide vigil! Please use /close or the Close Post button 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.

hot nexus
#

couldn't you just sort them normally

#

a lot of sorts are in-place and don't use much more memory

wide vigil
#

Would you mind giving an example?

hot nexus
#

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

proper pulsar
#

alternatively, just swap them in place

#

that'd take a bit long tho

#

builtin timsort would probably be the best option

hot nexus
#

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)