Wednesday, 6 December 2017

Stack Data Structure:

A stack is a list of elements in which an element may be inserted or deleted only at one end, called the top of the stack. Stacks are sometimes known as LIFO (last in, first out) lists.
As the items can be added or removed only from the top i.e. the last item to be added to a stack is the first item to be removed.
The two basic operations associated with stacks are:
a. Push: is the term used to insert an element into a stack.
b. Pop: is the term used to delete an element from a stack.
“Push” is the term used to insert an element into a stack. 
“Pop” is the term used to delete an element from the stack.
All insertions and deletions take place at the same end, so the last element added to the stack will be the first element removed from the stack. When a stack is created, the stack base remains fixed while the stack top changes as elements are added and removed. The most accessible element is the top and the least accessible element is the bottom of the stack.

Applications of stacks Data Structure:
a. Stack is used by compilers to check for balancing of parentheses, brackets and braces.
b. Stack is used to evaluate a postfix expression.
c. Stack is used to convert an infix expression into postfix/prefix form.
d. In recursion, all intermediate arguments and return values are stored on the processor‟s stack.
e. During a function call the return address and arguments are pushed onto a stack and on return they are popped off. 


Thanks
Mukesh Rajput

No comments:

Post a Comment

Thanks
Mukesh Rajput