Friday, 1 December 2017

Stack Data Structure

Stack is an ordered collection of data elements into which new elements may be inserted and from which elements may be deleted at one end called the “TOP” of stack.
a. A stack is a last-in-first-out ( LIFO ) structure.
b. Insertion operation is referred as “PUSH” and deletion operation is referred as “POP”.
c. The most accessible element in the stack is the element at the position “TOP”.
d. Stack must be created as empty.
e. Whenever an element is pushed into stack, it must be checked whether the stack is full or not.
f. Whenever an element is popped form stack, it must be checked whether the stack is empty or not.
g. We can implement the stack ADT either with array or linked list.

Applications of stack:
1) Stacks are used in conversion of expression from infix notation to postfix and prefix notation.
2) Stacks are used for evaluation of infix and postfix forms.
3) Stacks are used in tree traversal techniques.
4) Recursive functions are implemented using stacks. The copies of variables at each level of recursion are stored in stack.
5) Compilers use stacks in syntax analysis phase to check whether a particular statement in a program is syntactically correct or not.
6) Computers use stack during interrupts and function calls. The information regarding actual parameters return values, return addresses and machine status is stored in stack.
7) Stacks are used in depth first search of a graph.


Thanks
Mukesh Rajput

No comments:

Post a Comment

Thanks
Mukesh Rajput