3 ms·
It's not equally inefficient. The former will trash the CPU cache on large lists, whereas the latter will not if the k is small.
by DenisM 17y ago
It's not equally inefficient. The former will trash the CPU cache on large lists, whereas the latter will not if the k is small.
- cperciva 17y agoTrue. But the author hadn't gotten to the point of counting operations yet, so I don't think he was trying to make a subtle point about memory hierarchies and non-constant access times. :-)