Question: 2. Dynamic Arrays Revisited (40 points) A dynamically re-sizing array is an array that is initially allocated at size 1, and every time you need

 2. Dynamic Arrays Revisited (40 points) A dynamically re-sizing array is

2. Dynamic Arrays Revisited (40 points) A dynamically re-sizing array is an array that is initially allocated at size 1, and every time you need to insert past the end of the array you double its size and copy elements from the old array to the new array. In class, we showed that n inserts into a dynamic array can be accomplished in O(n) using an accounting argument where we pre-paid $3 for each insert, thus pre-paying for its doubling and the doubling of one older element. (a) Formally write the proof for this accounting (b) Show the same bound using the potential method (c) Does this O(n) bound on n operations hold if you include deletions? Why or why not? (Credit will be given for soltions that prove that a bound does work with particular array assumptions)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!