Stacks:
A
stack is a list in which all insertions and deletions are made at one
end, called the top of the stack. The last element to be inserted into
the stack will be the first to be removed. Thus stacks are sometimes
referred to as Last In First Out (LIFO) Data structures.
stacks are used in evaluating expressions, for keeping track of function calls and in recursion etc.
Operations on a stack:
InitStack(Stack) :
creates an empty stack.
Push (Item) :
pushes an item on the stack.
Pop(Stack):
removes the first item from the stack.
Top(Stack
):
returns the first item from the stack
w/o removing it.
isEmpty(Stack):
returns true if the stack is empty.
IsFull(stack):
returns true if the stack is full.
Stack overflow:
The condition resulting from trying to push an element onto a full stack.
if(!stack.IsFull())
stack.Push(item);
Stack underflow:
The condition resulting from trying to pop an empty stack.
if(!stack.IsEmpty())
stack.Pop(item);
Implementation of stacks:
We
provide stacks in c for the educational purposes only. We do not
responsiable
for the correctness of its contents. the risk of using it lies
entirelywith the user.