To Represent a Mathematical Operation and flow of processes in a tree.
- Track and represent the flow of math operations in a tree.
- python 3.0 or above
Run python3 tree_operation_representation.py
Input Arithmetic Operation:(8-10+(55/11)*21-99+(79*21/1000))
8 - 10 + 55 / 11 * 21 - 99 + 79 * 21 / 1000
---------------------------------------------------------------
55 11
\//
5
---------------------------------------------------------------
8 - 10 + 5 * 21 - 99 + 79 * 21 / 1000
---------------------------------------------------------
79 21
\ * /
1659
---------------------------------------------------------
8 - 10 + 5 * 21 - 99 + 1659 / 1000
------------------------------------------------------
1659 1000
\//
1
------------------------------------------------------
8 - 10 + 5 * 21 - 99 + 1
--------------------------------------------
5 21
\ * /
105
--------------------------------------------
8 - 10 + 105 - 99 + 1
-------------------------------
8 10
\- /
-2
-------------------------------
-2 + 105 - 99 + 1
---------------------------
-2 105
\ + /
103
---------------------------
103 - 99 + 1
----------------------
103 99
\-/
4
----------------------
4 + 1
---------------
4 1
\+/
5
---------------
Result: 5