Sort no more than 10 million 7-digit numbers. Limitations: 1M RAM, high speed. few seconds are good

Sort no more than 10 million 7-digit numbers. Limitations: 1M RAM, high speed. a few seconds are good.

[Edit: from comment by questioner: input values ​​are different]

Using a Bitmap data structure is a good solution to this problem.

This means that I need a string whose length does not exceed 10 million ???? Is RAM enough for this? confused here. Thanks you

+3
source share
2 answers

, 1 ~ 8 000 000 , 7- ( 9,999,999), - , . , , {0,1} .

, , , , ), 0 8 000 000 , 8 000 000 , , . - 1.

(0 - 10 , ), , ram, , ( ). python: http://neopythonic.blogspot.com/2008/10/sorting-million-32-bit-integers-in-2mb.html

+10

, 8 . . . 2 , 2 . . . .

+3

Source: https://habr.com/ru/post/1793472/


All Articles