Balancing Parenthesis
A program to check if the parenthesis are balanced in an equation.
Procedure :
Iterate through the input equation character by character.
If an opening bracket is found, push it to stack.
If a closing bracket is found, pop from the stack and check if the popped bracket and the closing bracket match (are of the same type).
If stack is empty and a closing bracket is found, the parenthesis are not balanced.
If the stack is empty after iterating through all the characters, the parenthesis are balanced. Else, they are not balanced.
C Function :
Contributed by Nitin Ranganath
Last updated