I'm a fan of the actual (in-RAM, no tricks) problem and its variants. The entropy of the sorted list is 0.96MiB so it is theoretically possible (see https://news.ycombinator.com/item?id=4679756 ), but I've not seen a good writeup of an actual algorithm. My personal favorite variant of this is sorting 1M 32-bit integers using 2MiB of RAM. This is possible and I coded it up for fun a few years ago. Here's the specific…
I think the second solution from SO is almost the same as yours, including having begun with Golomb coding: http://preshing.com/20121026/1mb-sorting-explained However, they explain that Golomb coding isn't quite enough for the 1M case and switch to arithmetic coding instead.
Sorting 1M 8-digit numbers in 1 MB of RAM (2012)
61–63 of 63 posts
Re: Sorting 1M 8-digit numbers in 1 MB of RAM (2012)
#62Its easy. 1kk numbers fit almost whole 1MB. So most of the numbers from the range will be there if we assume normal distribution. So we need to compress the data first in a way we can still count it. So we take a sinus function and mark multipliers where a number does not fit sinus. So we spare 0,5MB of RAM at least. Then we iterate the range, multiply sinus and output sorted numbers. Rest of the RAM can be used for…
Bitcoin mining hinges on computing hashes, though.
Re: Sorting 1M 8-digit numbers in 1 MB of RAM (2012)
#63The accepted answer seems prone to losing data on dropped packets, no? A similar (but I think safer) approach might be to read ahead all the packets to determine what values you can begin to send. Then you could request retransmission. This requires the sender to play nice and buffer all the data fore you but that seems more realistic than assuming the router will do so.