I’m practicing my knowledge of ADTs by implementing some data structures, even if most already exist. With Stacks, a lot of books and other documentation I’ve read talk about the stack throwing an error when you try to add an element but the stack is full. In a java implementation (or any other), should I specifically keep track of a maximum stack size (from constructor), check to see if that size is reached, and throw an overflow exception if it is?
Or is not such a big deal?
I’m practicing my knowledge of ADTs by implementing some data structures, even if most
Share
Depends on the kind of stack, but usually, it doesn’t matter about size if the stack is heap-allocated.
If your stack is really allocated on the stack, then you should keep it small.