What does Wikipedia mean when it says the complexity of inserting an item at the end of a dynamic array is O(1) amortized?
问题 http://en.wikipedia.org/wiki/Dynamic_array#Performance What exactly does it mean? I thought inserting at the end would be O(n), as you'd have to allocate say, twice the space of the original array, and then move all the items to that location and finally insert the item. How is this O(1)? 回答1: Amortized O(1) efficiency means that the sum of the runtimes of n insertions will be O(n), even if any individual operation may take a lot longer. You are absolutely correct that appending an element