Двоичное дерево выражений C ++

У меня небольшая проблема. Я'я пытаюсь добавить математическое выражение в двоичное дерево, но я не могуне понимаю алгоритм. Вот:

If the current token is a '(':
 Add a new node as the left child of the current node, and 
 descend to the left child.
If the current token is in the list ['+','-','/','*']:
 Set the root value of the current node to the operator represented by the current token.
 Add a new node as the right child of the current node and descend to the right child.
If the current token is a number:
 Set the root value of the current node to the number and return to the parent.   
If the current token is a ')':
  go to the parent of the current node.

и код, который я сделал до сих пор:

template
void Tree::Expr(Node *node, char expr[], int &i)
{
    i++;
    T x = expr[i];
    if(x == '(')
        {
            node = node->Left;

            node = new Node;
            node->Left = NULL;
            node->Right = NULL;
            Expr(node, expr, i);
        }
    if(x == '+' || x == '-' || x == '*' || x == '/')
        {
            node->data = x;
            node = node->Right;
            node = new Node;
            node->Left = NULL;
            node->Right = NULL;
            Expr(node, expr, i);
        }
    if(x >= '0' && x data = x;
            return;
        }
    if(x == ')') return;
}

Я знаю это'большой беспорядок но я могуне понимаю, как это реализовать. Может кто-нибудь объяснить мне алгоритм или дать мне исходный код с C ++ или лучше объяснил алгоритм?

Постскриптум Вот новый код, который я написал, но он работает только для таких выражений, как: (5 + 2)

template
void Tree::Expr(Node *&node, char expr[], int &i)
{
    i++;
    if(i >= strlen(expr)) return;
    char x = expr[i];
    node = new Node;
    node->Left = NULL;
    node->Right = NULL;
    if(x == '(')
        {
            Expr(node->Left, expr, i);
            i++;
            x = expr[i];
        }
    if(x >= '0' && x data = x;
            return;
        }
    if(x == '+' || x == '-' || x == '*' || x == '/')
        {
            node->data = x;
            Expr(node->Right, expr, i);
        }
    if(x == ')') return;
}

Ответы на вопрос(1)

Ваш ответ на вопрос