While support for undo can be implemented with an unboundedstack, many applications provide only limited support for such anundo history, with a fixed-capacity stack. When push is invokedwith the stack at full capacity, rather than throwing an exception,a more typical semantic is to accept the pushed element at the topwhile “leaking” the oldest element from the bottom of the stack tomake room. Give an implementation of such a LeakyStack abstraction,using a circular array.
this has to have an UndoStack as well.
Solution
Requirement: As per theproblem, we need to write an array implementation for theLeakyStack class where the array
OR
OR