Storage Algorithm Question - Verifying Serial Data with Small Memory

I found this on the "interview questions" website and pondered it for a couple of days. I will continue to chat, but I wonder what you guys think

"10 GB of 32-bit tape numbers, everything is from 0 to 10G in random order. You have 64 32-bit memory words: design an algorithm to check that every number from 0 to 10G happens once and only one times on a tape with minimal tape passes using a read head connected to your algorithm. "

+3
source share
6 answers

Do 2 reducefor numbers, sum and bitwise XOR.

(10G + 1) * 10G/2
XOR ... -

-1

, . 10G 32b 10G. () () , , .

+1

32- 4G = 2 ^ 32 . 2,5 * 2 ^ 32 . 2 ^ 32 100%. <= 2 ^ 32, , - .

+1

quicksort, ? , , = + 1.

, , .

: oh bugger, , .

: 30- . IE 1,2,3,4,5 , 8,9,10,11,12 .. , . , , , ... , , , .

, .

0

, , , , , , . , , . .

, , , - 64 , 64 , , , - . O (n) , .

, , - , , 32- .

0

, , . ,

(i) , 10G, - , ? , , , , ( , )? , , , .

(ii) , 10G , ; ? , , , , ?

, , , 10 , 64 32- ; , , ; , ?

, , , ; wold ?

, Samba

-1

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


All Articles