hi
so this code here as i test it on paper provides paranthesis on every leaf node, disregarding priority (operator precedence)
how can i make it add those paranthesis based on precedence of operators?
void printInfix(Node n)
{
if (n == null)
{
if (n.isLeaf())//if n is a leaf, therefore a number
System.out.print(n.element);
else//n is not a leaf
{
System.out.print("(");
printInfix(n.left);
System.out.print(n.element);
printInfix(n.right);
System.out.print(")");
}//end else
}//end if
}