Closed
Description
Repository commit
Python version (python --version)
Python 3.10.6
Dependencies version (pip freeze)
astroid==2.11.3
bcc==0.18.0
black==22.3.0
blinker==1.4
Brlapi==0.8.3
certifi==2020.6.20
chardet==4.0.0
Expected behavior
Hi, In the data_structures/stacks/infix_to_postfix_conversion.py file, when we pass "2^3^2"
argument to the infix_to_postfix
function, it should return '2 3 2 ^ ^'
back. This results in number 512
which is the correct calculation.
Actual behavior
Currently infix_to_postfix("2^3^2")
returns '2 3 ^ 2 ^'
which is wrong. If we calculate it, it returns number 64
.
The reason behind this is that currently we don't have any check for the "associativity" of the operators. In particular ^
operator causes problem here. It has Right-To-Left
associativity.