7.5IMPLEMENTATION OF A STACK
Stacks can be represented by two data structures:
1.using arrays
2.using a linked list
7.5.1Implementation of Stacks Using Arrays
Stacks can be easily implemented using arrays. Initially, the TOP of the stack points at the first position or location of the array. As we insert new elements into the stack, the TOP keeps on incrementing, always pointing to the position where the next element will be inserted. The representation of a stack using an array is shown as follows:

FIGURE 7.6 Array representation of a stack
7.5.2Implementation of Stacks Using Linked Lists
We studied how a stack is implemented using an array. Now let us discuss the same using linked lists. We already know that in linked lists, dynamic memory allocation takes place; that is, the memory is allocated at runtime. But in the case of arrays, memory is allocated at the start of the program. If we are aware of the maximum size of the stack in advance, then the implementation of stacks...