News for hackers. Stuff that matters.
Re:When your data doesn’t fit in memory: the basic techniques by bogomipz on Monday November 11, 2019 @07:39PM (#21510432)
>The naive solution will use O(n) space, while a bit more thought reveals that this can be done in constant (to be really precise, O(log n) where n is the number of lines in the file) space"

Can you elaborate on the O(1) solution?

Re:When your data doesn’t fit in memory: the basic techniques by xondono on Tuesday November 12, 2019 @03:41AM (#21512565)
Not an expert, but after reading around OP is saying you only need a constant sized buffer (that could be as little as a character deep) to read the whole file looking for line breaks. This roughly takes O(1) space (A lot of commenters are confusing time vs space requirements) but there's a little nitpick to be found, in extremely big files the line counter itself would be O(log(n)) and would dominate.
Re:When your data doesn’t fit in memory: the basic techniques by bogomipz on Tuesday November 12, 2019 @09:14AM (#21514211)
I see, yes that makes sense. The conflation with time instead of space was confusing me. Thanks.