Question: We have seen how dynamic arrays enable arrays to grow while still achieving constant-time amortized performance. This problem concerns extending dynamic arrays to let them

 We have seen how dynamic arrays enable arrays to grow while

We have seen how dynamic arrays enable arrays to grow while still achieving constant-time amortized performance. This problem concerns extending dynamic arrays to let them both grow and shrink on demand. a) Consider an underflow strategy that cuts the array size in half whenever the array falls below half full. Describe a sequence of insertions and deletions where this strategy gives a bad amortized cost. b) Give a better underflow strategy than suggested above, one that always achieves constant amortized cost per deletion. We have seen how dynamic arrays enable arrays to grow while still achieving constant-time amortized performance. This problem concerns extending dynamic arrays to let them both grow and shrink on demand. a) Consider an underflow strategy that cuts the array size in half whenever the array falls below half full. Describe a sequence of insertions and deletions where this strategy gives a bad amortized cost. b) Give a better underflow strategy than suggested above, one that always achieves constant amortized cost per deletion

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!