A Stack Is A Container of Objects That Are Inserted and Removed According To The
A Stack Is A Container of Objects That Are Inserted and Removed According To The
the last-in first-out (LIFO) principle. In the push-down stacks only two
operations are allowed: push the item into the stack, and pop the item out of
the stack.
o A stack is a limited access data structure - elements can be added and
removed from the stack only at the top.
o push adds an item to the top of the stack, pop removes the item from the top.
A stack is a recursive data structure. Here is a structural definition of a Stack:
o a stack is either empty or
o it consists of a top and the rest which is a stack
2. Application :-
To reverse a word. You push a given word to stack - letter by letter - and
then pop letters from the stack.
An "undo" mechanism in text editors; this operation is accomplished by
keeping all text changes in a stack.
o Undo/Redo stacks in Excel or Word.
Language processing :
o space for parameters and local variables is created internally using a stack.
o compiler's syntax check for matching braces is implemented by using stack.
A stack of plates/books in a cupboard.
A garage that is only one car wide. To remove the first car in we have to
take out all the other cars in after it.
Wearing/Removing Bangles.
Back/Forward stacks on browsers.
Support for recursion
o Activation records of method calls.