
484 Programming and Data Structures
Empty
stack
TOP
8 TOP !
5
2
push (8)
Fig. 14.11 (a) Push operation with stack
Stack initially pop (8) pop (2) Empty stack
(b) PoP operation with stack
14.14 IMPLEMENTATION OF A STACK
The stack implementation can be done in the following two ways.
1) Static implementation: Static implementation can be achieved using arrays. Though, it is a very
simple method, but it has a few limitations. Once the size of an array is declared, its size cannot be
altered during program execution. While in array declaration, memory is allocated equal to array
size. The vacant space of stack (array) also occupies memory spa