by seanmcdirmid · 7y ago · 0 comments
> In typical access patterns, they are faster than mutable arrays.
Only if typical is extremely random on large lists that consume many pages/cache lines.
Edit: That's true about log32 and log2 become close in the limit, but that's irrelevant for practical data sizes. For example,
log2(10^6) ~ 20,
log32(10^6) ~ 4
That's a 5x difference.
There is a good reason why the subscript of log is often not even mentioned. Logarithmic is logarithmic, no longer what subscript you bother in investing extra space for.
Case in point, if your algorithm takes log32n operations but each OP takes 5x longer its exactly the same as log2n. This is true for any value n, not just large values.