How to solve linear equation with binary tree I'm working on a school project that takes in a simple linear equation and has to return the value of $x$. The code I have transforms $x + 3 = 3x - 2$ into a binary tree format like so:

        =
      /   \
     /     \
    +       -
   / \     / \
  x   3   *   2
         / \
        3   x


With the expression in this format could someone please explain how can I obtain the value of $x$.
Any help is appreciated - if you have an alternative method that may make it easier I'd love to hear it.
For solving this question you should assume a tree with '=' root
And in the left side of root push factors of x and in the right side push your constant values, now variable x is equal to sum of right side division by left side.