Here you will learn about applications of stack.
Stack is an abstract data type and a data structure that follows LIFO (last in first out) strategy. It means the element added last will be removed first. Stack allows two operations push and pop. Push adds an element at the top of the stack and pop removes an element from top of the stack.
Below I have mentioned few applications of stack data structure.
Applications of Stack
Expression Evaluation
Stack is used to evaluate prefix, postfix and infix expressions.
Expression Conversion
An expression can be represented in prefix, postfix or infix notation. Stack can be used to convert one form of expression to another.
Syntax Parsing
Many compilers use a stack for parsing the syntax of expressions, program blocks etc. before translating into low level code.
Backtracking
Suppose we are finding a path for solving maze problem. We choose a path and after following it we realize that it is wrong. Now we need to go back to the beginning of the path to start with new path. This can be done with the help of stack.
Parenthesis Checking
Stack is used to check the proper opening and closing of parenthesis.
String Reversal
Stack is used to reverse a string. We push the characters of string one by one into stack and then pop character from stack.
Function Call
Stack is used to keep information about the active functions or subroutines.
Video Tutorial
There are various other applications of stack. I have mentioned some of them. Comment below if you found any mistake in above article.
A stack can also be used for tracking local variables at runtime.
Stack helps in managing undo funtion….
good idea! thanks
still more applications of stack
thank you for your information.
thanks for that information but need to include small examples for each application.
One more application it has supports is Depth first search
This article includes “Stack allows two operations push and pop”… Which is partially incorrect…
The basic operations in stack are two which are push() and pop(). But operations in stack are more than two…
Stack is used in recursion.
Stack is also used in back tracking the path…
Stack is linear data structure
It is a non-primitive , Linear data structure which follow the principle of last in first out to access elements.
Push()&pop()
Also OS uses stack for scheduling algorithm
push and pop
Stack is flow by FIFO Principle not LIFO
it follows LIFO
No FIFO for queue
May be u have got some misunderstanding !
First Come First Go or First in first Out …it is used in Queue
stack used FILO or FOLI
Tell me about to the Big 0notation
Stack can be used for implementing Quick sort
Stack is follows two principles that are LIFO AND FILO
The stack is the list of elements in which an element may be inserted or deleted only at the end
What is different between system software and application software
hi pleas can help me for short report about one aemplemation of stack in one application
Recursion is also implemented through Stack.