Question: Let's consider only two operations: INSERT, in which a single element is inserted into an array with available space, and INSERTEXPAND, in which the array
Let's consider only two operations: INSERT, in which a single element is inserted into an array with available space, and INSERTEXPAND, in which the array is full, so in order to insert an element we first copy all elements of the array into a new array twice the size doubling the array
a First, use the accounting approach to prove that inserting n elements in a dynamic array needs On amortized time.
b Suppose we change our model for how much we increase the size of our array when it is full. For each of the three options below, indicate whether or not we can still achieve On amortized time for n operations. If yes, what would change in the previous proof argument? If not, explain why not.
i Quadrupling the array.
ii Increasing the size of the array by only
iii. Increasing the size of the array by a constant each time
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
