Total  Amortized time complexity

But let’s be accurate for the worst time complexity without simplifying this time. 

  • If the internal array capacity starts with 1, then the capacities will be 1, 2, 4, 8, 16… X when it hits the capacity and gets doubled. 
  • It takes 1, 2, 4, 8 16 … X items to copy into the new array depending on the capacity that has been reached. 
  • So the time complexity will be 1 + 2 + 4 + 8 + 16 +… X. If you think from X, this will be X + X/2 + X/4 + X/8… + 1 = 2X approximately.

We try to show that even though some of the operations may be expensive, the sum (or, equivalently, the average) of their running times always has to be small.

We can understand it with the help of a diagram which contains an explanation about it with an example:
 

Potential Method in Amortized Analysis

Similar Reads

What is Amortization?

Consider that you are a company owner and that you require a vehicle. The automobile is priced at €10, 000. You’ll have to spend €10, 000 if you decide to purchase it this year. But you want to keep driving the automobile for the next ten years. An additional €1, 000 is needed to operate the automobile for a year.There are two different angles from which to view the aforementioned circumstance. The first method is the one we employed above: there is a year with a high level of spending followed by nine years with lower levels....

Amortized Time Complexity

Amortized complexity is the total expense per operation, evaluated over a sequence of operations or we can also say average time taken per operation if you do many operations....

Total  Amortized time complexity

But let’s be accurate for the worst time complexity without simplifying this time....

What is the Potential method?

According to computational complexity theory, the potential method is defined as:...

Analysis of potential method with example

Stack operationsPush operation: Time complexity to push an item into a stack is O(1)...