Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dynamic shrinking. With the array implementations of stack and queue, we doubled the size of the array when it wasn’t big enough to store the next element. If we perform a number of doubling operations, and then delete a lot of elements, we might end up with an array that is much bigger than necessary. Implement the following strategy: whenever the array is 1/4 full or less, shrink it to half the size. Explain why we don’t shrink it to half the size when it is 1/2 full or less.
-
- Stacks at PU
- https://algs4.cs.princeton.edu/13stacks/
- Stacks
- http://algorithms.mrseliasclasses.org/2-stacks-problems/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement