我被一位面試官問到,問題很簡單,find the top 100 from 1 million integers (32-bits)
。關於文件I/O的困惑
當我解決問題時,我想如果我put all the 1 million integers into the memory
,這將佔用4 MB space
。
我的問題可能有無關的面試問題,但在這裏它是:
如果100萬個整數是在一個文件num.txt
店,並進一步,我想文件和put them in memory
的read the all out
(將它們存儲在數組中),然後how many IO will it take
?
其實,先生,最大的最大3.8兆字節。除非每個整數都使用全部32位小數,否則可能會得到小得多的結果。對?假設百萬位數的一半隻有16位,只得到2.86102295兆字節。 – FreeSnow
@DadeLamkins,是的,你說得對,但是我想知道的是,如果我想從文件中讀取所有32位整數,它應該採用多少IO。 – Alcott