Hacker News new | ask | show | jobs
by herewhere 3855 days ago
if 4 <= N <= 16, then sqrt(N) <= log2(N) else sqrt(N) > log2(N)

So, in Big-O term, this only trying to optimize only small dataset (4 <= N <= 16).

2 comments

Big-O is only strictly meaningful in terms of asymptotic behavior; as soon as you start talking about specific values of N, you have to care about constant factors.

In this case, the constant factors will probably be quite different because the goal is to make better use of CPU cache.

I mean, it depends on your data access patterns. Arrays are good for some things, trees are good for other things. Here's another option.