Re:When your data doesn’t fit in memory: the basic techniques
by unlivingthing on Monday November 11, 2019 @09:55PM
(#21511147)
I think you've got confused with O(n) time; that is the amount of memory that is needed and not the time required to access a particular line.
Re:When your data doesn’t fit in memory: the basic techniques
by tmh88j on Monday November 11, 2019 @10:02PM
(#21511186)
Good point, I was thinking in terms of time complexity rather than space, but the title clearly is in reference to memory. I guess that explains my confusion!
Re:When your data doesn’t fit in memory: the basic techniques
by profmonocle on Monday November 11, 2019 @10:04PM
(#21511201)
I made the same mistake at first, had to reread the post. I'm so used to seeing Big O notation used for time that I guess my eyes just passed over the word "space".
(My mistake obviously, the OP was very clear.)
I guess I'm misinterpreting the task, because I'm having trouble seeing how it's possible to access each line in a file without it being O(n) at a minimum. I understand O(log n) to mean that not every data point is "accessed" due to the way the data structure is organized, lines of a file in this case, but to me it appears that not every line would be prepended with a number. My instinct is that there's a lot going on with new lines/line breaks in files that I'm not aware of, so I'd really appreciate any reading material on the subject to help me better understand this. Thanks!