News for hackers. Stuff that matters.
Re:JavaScript Array.push is 945x faster than Array.concat by slavik81 on Thursday May 23, 2019 @12:39PM (#19993297)
The number of copies required is a geometric series. With a growth factor of 2x, the number of total copies is only 2N - 1. Thus, it is O(N).

It's O(N) for any geometric growth rate, but using 2x makes it easy to see, because every copy is one larger than all previous copies combined. Consider a concrete example for N=9: 1 + 2 + 4 + 8 = 7 + 8.

There are no comments on this comment yet.