2 ms·
People usually underestimate where that line is. In my past experience, I ended up benchmarking binary search vs linear search on a collection of small objects
by pclmulqdq 4y ago
People usually underestimate where that line is. In my past experience, I ended up benchmarking binary search vs linear search on a collection of small objects. The breakeven point on a modern CPU was at 10 megabytes of data. Although this is a particularly extreme example, most people assume that collections of a few thousand items are where you should switch to big-O-optimal algorithms, but the breakeven is usually several orders of magnitude higher.
- AgentOrange1234 4y agoThat’s very surprising to me. My intuition screams that surely a binary search is competitive with a linear search even at small sizes. I would love to see benchmarks and code for this if you have them handy.