As seen in the documentation for TimeComplexity, Python\'s list
type is implemented is using an array.
So if an array is being used and we do a few appe
This is very easy.
We can calculate this by accumulating the total time of appending n elements into an arraylist and divide it by n.
Firstly, we need to relocate log(n) times, and every relocation is doubled by 2.So we have a proportional series whose ratio is 2, and the length is log(n).
The sum of a proportional series is a(1-r^n)/(1-r) So the total time of relocation is (1-n)/(1-2)=n The time complexity would be n/n=1.