Question: We have an array that supports both insert and remove operations. This is an extendable - shrinkable array that does the following, where N is
We have an array that supports both insert and remove operations. This is an extendable
shrinkable array that does the following, where N is the current capacity of the array:
when there are N elements and we insert one more, the array is extended so the new
capacity is N
when we remove an element so the number of elements dips below N we shrink the
array so the new capacity is
a Show that a sequence of n insert and remove operations, starting from an extendable
shrinkable array of capacity takes time. Use the accounting method, but be very
clear about what is getting "paid forward" towards what.
b What can you conclude about the amortized time of the insert and remove operations for this
extendableshrinkable array?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
