Stack:
A stack is a
linear data structure in which an
element is inserted or deleted only at one end called the top end of the stack
i.e. the elements are removed from a stack in the reverse order of that in
which they were inserted into the stack.
A
stack follows the principle of last-in-first-out (LIFO) system. According to
the stack terminology, PUSH and POP are two terms used to insert and delete
operations.
In a stack, the insertion operation is performed using a
function called "push" and deletion operation is performed using a
function POP.
Array Representation of Stack:
A
stack may be represented by means of a one-way list or a linear array. Unless,
otherwise stated, each of the stacks will be maintained by a linear array
STACK; a variable TOP contains the location of the top element of the stack. A
variable N gives the maximum number elements that can be held by the stack. The
condition where TOP is NULL, indicate that the stack is empty. The condition
where TOP is N, will indicate that the stack is full.
Different
Implementation of Stack:
Stack data
structure can be implementing in two ways. They are as follows:
1. Using
Array
2. Using Linked List