Re:The true cost of linked lists
by magicalhippo on Monday June 06, 2022 @08:53AM
(#31639827)
Indeed. I do think knowing about big-O and keeping it in mind is important though.
Yes this loop is fast now with my 1000 items, but what if the input grows to 100000 or more?
Keeping it in mind can also help you avoid accidentally writing O(n^2) loops or worse. More than once I've been unsure about the complexity of a library call, so I check the code and it's say O(n) rather than O(1), potentially turning my own O(n) into a O(n^2).
Yes this loop is fast now with my 1000 items, but what if the input grows to 100000 or more?
Keeping it in mind can also help you avoid accidentally writing O(n^2) loops or worse. More than once I've been unsure about the complexity of a library call, so I check the code and it's say O(n) rather than O(1), potentially turning my own O(n) into a O(n^2).