Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding in the evaluate postfix notation using Stack #2598

Merged
merged 12 commits into from
Oct 16, 2020
Prev Previous commit
Next Next commit
Update evaluate_postfix_notations.py
fixing pre-commit fails
  • Loading branch information
akashgkrishnan authored Oct 16, 2020
commit 3668d564dc69f0bfca517bb05c5cbb6f468d311f
8 changes: 4 additions & 4 deletions data_structures/stacks/evaluate_postfix_notations.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
The Reverse Polish Nation also known as Polish postfix notation or simply postfix notation
The Reverse Polish Nation also known as Polish postfix notation
or simply postfix notation.
https://en.wikipedia.org/wiki/Reverse_Polish_notation
Classic examples of simple stack implementations
Valid operators are +, -, *, /. Each operand may be an integer or another expression.
Valid operators are +, -, *, /.
Each operand may be an integer or another expression.
"""


def evaluate_postfix(postfix_notation):
akashgkrishnan marked this conversation as resolved.
Show resolved Hide resolved
"""
>>> evaluate_postfix(["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"])
22
>>> evaluate_postfix(["2", "1", "+", "3", "*"])
9
>>> evaluate_postfix(["4", "13", "5", "/", "+"])
Expand Down