Given algebraic expression in a string, I want to split it into a list of operations for building a parallel binary tree. For example, I'm trying to convert expression such as:
or same expression in postfix notation:
into a list of
Expr1 = 'a+b' Expr2 = 'c+d' Expr3 = 'e*f' Expr4 = 'Expr1+Expr2' Expr5 = 'Expr4/Expr3'
However,parsing expression iteratively I've only managed to turn it into a list like this:
Expr1 = 'a+b' Expr2 = 'Expr1+c' Expr3 = 'Expr2+d' Expr4 = 'e*f' Expr5 = 'Expr3/Expr4'
Is there any algorithm to parse expression into a list of operations, which can be computed as parallel as it's possible? Any help will be appreciated.