 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
So,
which data structure is best for a stack?
|
|
|
| • |
If
we know at compile time the size of the stack,
|
|
|
and
if that size doesn’t vary greatly, and if all
|
|
|
objects
of the class require the same size
|
|
|
|
– |
then
use statically allocated arrays
|
|
|
| • |
If
we know at run time (before we use the stack),
|
|
how
large the stack should be, it is manageable
|
|
|
and
doesn’t vary greatly
|
|
|
|
– |
then
use a dynamically allocated array
|
|