Parenthesis matching algorithm
PARENTHESIS_MATCHING (EQ, VALID)
This algorithm checks whether the expression EQ written in infix notation is valid or not and assigns TRUE or FALSE to VALID.
1. Scan EQ from left to right until the end of the equation is encountered:
2. If”(“is encountered then: put it in the STACK.
3. If the closing bracket is encountered then:
(a) If STACK is empty, then Set VALID: = FALSE and return.
(b) Pop the “(” from the STACK.
[End of If structure.]
[End of Step 2 loop.]
4. If STACK is empty, then:
Set VALID := TRUE
7. Else:
Set VALID := FALSE
[End of If structure.]
8. Return
Miriam Mitchell
I like the efforts you have put in this, regards for all the great content.
Parker Robinson
I am truly thankful to the owner of this web site who has shared this fantastic piece of writing at at this place.