I have this build method for my expression tree. I want to build it in infix but its not coming out correctly. So, I was wondering if anyone can help me. Thanks.
private TreeNode build(Scanner input)
{
boolean leaf;
String token;
int value;
TreeNode node;
leaf = input.hasNextInt();
if (leaf)
{
value = input.nextInt();
node = new TreeNode(leaf, '\0', value);
}
else
{
token = input.next();
node = new TreeNode(leaf, token.charAt(0), 0);
node.left = build(input);
node.right = build(input);
}
return node;
}