I've found that there is a lot of controversy about asymptotic complexity of List.Add()
. The source of it I suspect is the worst case scenario that causes underlying array to resize and would logically be O(n)
operation. However, the array grows twice in size each time list runs out of space. That makes amount of resizes needed for n
elements be proportional to log(n)
.
Does not that mean that asymptotic complexity of Add
operation in average case will be O(n/log(n))
?
The real benchmark for List.Add()
is below. However, benchmarks are not really expressive for such operation - we might be running out of memory prior to any deviation from straight (in logarithmic scale) line becomes visible.