Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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? 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started