3 ms·
In the case of C++ it is often noted by library writers that simple implementations often beat their most complex efforts in the real world: between the compile
by bluGill 6y ago
In the case of C++ it is often noted by library writers that simple implementations often beat their most complex efforts in the real world: between the compiler optimizing better, and simple algorithms leading to less CPU stalls because of a cache miss
In the real world O(n) is faster than O(log n) on all real data. (that is data that fits in RAM)
- quicknir 6y agoI would encourage you to benchmark linear search and binary search on a dynamic array (std::vector) of a million elements. You may be in for a surprise. I can only assume you have 4KB of ram.