Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions