mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
Update data_structures/stacks/infix_to_postfix_conversion.py
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
parent
01aebb0270
commit
78e9dc4c7a
@ -88,13 +88,13 @@ def infix_to_postfix(expression_str: str) -> str:
|
||||
if char_precedence > tos_precedence:
|
||||
stack.push(char)
|
||||
break
|
||||
elif char_precedence == tos_precedence:
|
||||
if char_precedence < tos_precedence:
|
||||
postfix.append(stack.pop())
|
||||
break
|
||||
# Precedences are equal
|
||||
if associativity(char) == "RL":
|
||||
stack.push(char)
|
||||
break
|
||||
else:
|
||||
postfix.append(stack.pop())
|
||||
else:
|
||||
postfix.append(stack.pop())
|
||||
|
||||
while not stack.is_empty():
|
||||
|
Loading…
x
Reference in New Issue
Block a user