1

Suppose we are given an array-based list data structure. Suppose that its initial capacity is $m > 0.$ When appending an element to the end of the list, if the list is full, we extend its capacity by $d > 0$ array components, copy the old content, and finally append the element. Suppose we are to append $n \geq m$ elements to the list. My claim is that the total work is: $$ C(n, m, d) = \overbrace{\sum_{k = 0}^{\big\lceil \frac{n - m}{d} \big\rceil}(kd + m)}^{A} - \overbrace{\Bigg( m + \Bigg\lceil \frac{n - m}{d} \Bigg\rceil d - n \Bigg)}^{R}. $$

Above, $A$ is the total work of expanding and filling (entirely) the array sufficiently many times in order to accommodate $n$ elements, and $R$ denotes the number of elements we could have put before expanding once again.

Now, I need to prove it using induction on $n$, yet I have no clue how to deal with it. Any help?

coderodde
  • 60
  • 1
  • 13

0 Answers0