1.
Expression Evaluation and Conversion
There are 3 types of expression we use in Programming, which
are Infix Expression, Prefix Expression and Postfix Expression.
Infix Expression is represented as X + Y. Prefix Expression is
represented as +XY and Postfix Expression is represented as XY+.
In order to evaluate these expressions in Programming, a Data
Structure called Stack is used.
Similarly, Stack is also used for Converting one expression into
another. For example, converting Infix to Postfix or Infix to Prefix.
2. Backtracking
Backtracking is a recursive algorithm which is used for solving the
optimization problem.
So, In order to find the optimized solution of a problem with
Backtracking, we have to find each and every possible solution of
the problem, doesn’t matter if it is correct or not.
In Backtracking, while finding the every possible solution of a
problem, we store the solution of a previously calculated problem
in Stack and use that solution to solve the upcoming problems.
3. Parenthesis Checking
In Programming, we make use of different type of parenthesis,
like – (, ), {, }, which are used for opening and closing a block of
code.
So, these parentheses get stored in Stack and control the flow of
our program.
4. Function Call
In Programming, whenever you make a call from one function to
the another function. The address of the calling function gets
stored in the Stack.
So, when the called function gets terminated. The program
control move back to the calling function with the help of the
address which was stored in the Stack.
So, Stack plays the main role when it comes to calling a Function
from other Function.
5. String Reversal
String Reversal is another amazing Application of Stack. Here, one
by one each character of the Stack get inserted into the Stack.
So, the first character of the Stack is on the bottom of the Stack
and the last character of the String is on the Top of the Stack.
After performing the pop operation in Stack, we get the String in
Reverse order.
6. Syntax Parsing
As many of the Programming Languages are context-free
languages. So, Stack is also heavily used for Syntax Parsing by
most of the Compilers.
7. Memory Management
Memory Management is the important function of the Operating
System. Stack also plays the main role when it comes to Memory
Management.