Upload
andrei-florin
View
215
Download
0
Embed Size (px)
Citation preview
7/24/2019 Am Mortised Analysis Errata
1/1
Algorithms & Complexity Theory
Ammortised Analysis Errata
The cost of a sequenceSof size n of operations of type insert, performed
on an initially empty arraylist is given by:
cost(S) =cost copy(S) +cost ins(S)
We analyse cost copy(S). We observe that:
2k1 < n 2k
for some k N. Moreover, k represents the number of times the arraylistcapacity was doubled. It follows that: k 1 < log(n) k, and thus k =log(n). The cost of the ith doubling is 2i1, hence:
cost copy(S) =
log(n)
i=1
2i1 =
log(n)1
i=0
2i
log(n)
i=0
2i = 2log(n)+1 1 = 2n 1
It follows that:cost(S) 3n
1