The following problem is based on the section about dynamic table as part of the discussion about amortized analysis in CLRS
Problem: We are given a dynamic table $T$ that supports INSERT operation, implemented as an array and allows a constant amortized time per operation. Change the data structure so that when the array is full its size is increased by $\sqrt{T.size} $, i.e., the new size is $T.size +\sqrt{T.size}$.
Show, that the amortized time per operation is $ \Theta( \sqrt{n} ) $, in other-words, show that the total complexity that is needed for a sequence of $ n $ operations in the W.C. is $ \Theta(n\sqrt{n}) $.
Attempt: I really have no idea, I've been stuck on this problem for a few days and I would really appreciate a fat hint. Here's what I did though,
Consider the $i$-th INSERT operation,
If we insert an element and there is no expansion of the table then
$ T.size_{i} = T.size_{i-1} $ , $ T.num_i = T.num_{i-1} + 1 $ , $ c_i = 1 $.
If we insert an element and there is an expansion of the table then
$ T.size_{i} = T.size_{i-1} + \sqrt{T.size_{i-1}} $, $ T.num_i = T.num_{i-1} + 1 = T.size_{i-1} + 1 $ , $ c_i = i+1 = T.size_{i-1} + 1 $
Where $ c_i $ is the cost of the $i $-th operation. $ T.size_i $ is the size of the table at the $i $-th operation. $ T.num_i $ is the number of elements in the table at the $i $-th operation.
Let us look at a sequence of $n$ TABLE-INSERT operations on an initially empty table.
If the current table has room for the new item (or if this is the first operation), then $c_{i}=1$
If the current table is full, however, and an expansion occurs, then $c_{i}=i:$ the cost is 1 for the elementary insertion plus $i-1$ for the items that we must copy from the old table to the new table.
The total cost of $n$ TABLE-INSERT operations is therefore
$\sum_{i=1}^{n} c_{i} \leq n+ [ ( 1+ \sqrt{1} ) + ( ( 1+ \sqrt{1} ) + \sqrt{ 1+ \sqrt{1} } ) + ... ] $
[ Well, this is it, I'm stuck from here on ( I made a few more things on a draft paper which I don't think are worth writing, one of them is trying to solve the recurrence relation when the table expands $ T.size_{i} = T.size_{i-1} + \sqrt{T.size_{i-1}} $, whose solution won't be of any value ). the $n$ comes from $n$ elementary insertions into the table. My trouble is the expression $ [ ( 1+ \sqrt{1} ) + ( ( 1+ \sqrt{1} ) + \sqrt{ 1+ \sqrt{1} } ) + ... ] $ which comes from the table's expansion, I'm stuck at realizing how many times we add this sum and what it sums to, this is my main difficulty in the problem. ]
I understood the section about dynamic tables in the book and its analysis as it appears in the book when the table size grows at a constant factor of 2, but due to the nature of the problem above ( the table size does not grow constantly ), I'm having trouble wrapping my head around it.
I have some direction for the amortized analysis using accounting method ( but nevertheless, I'm supposed to find the worst-case tight bound for the sequence of operations for which without, my amortized analysis won't have a validation ):
In the moment of the expansion of the table, if the number of cells was $ k $ then $ \sqrt{k} $ cells will be added. For every element that I'll put into the table i'll buy $ \sqrt{k} + 2 $ coins, one coin will be used for insertion and the rest I put into the bank, such that for every inserted element into the $ \sqrt{k} $ cells, I keep $ \sqrt{k} + 1 $ coins. I fill $ \sqrt{k} $ cells and thus, in the bank, I have at the end of the filling process, $ \sqrt{k}\cdot (\sqrt{k}+1 ) = k + \sqrt{k} $ coins. ( Now I'll have to talk about how to take out the coins out of the bank at the moment of the expansion to pay for the expensive operation of expansion, but this explanation is the heart of the amortized analysis explanation ).