Answers
First of All, the "Node" class is missing, you should add Node class then only you can access the object of the node.
A node class is given below and the properties and Constructor is given below.
So now you can access the Node object and you can return the expression tree without any exception.
//Code start Here
import java.util.Stack; // You need to add this class Node to your script // your accessing Node object without node class // so it throws exception class Node { char value; Node left, right; Node(char item) { value = item; left = right = null; } } /* The real ExpressionTree is started here write your code for expression tree Node constructTree(char postfix[]) { .. .. .. return t; */ //Also add main function in your code this will increase the chance to return your expecting //Expression Tree public static void main(String args[]) { ExpressionTree et = new ExpressionTree(); String postfix = "ab+ef*g*-"; char[] charArray = postfix.toCharArray(); Node root = et.constructTree(charArray); System.out.println("infix expression is"); et.inorder(root); } } // This code has been contributed by Mayank Jaiswal
//Code ends here
Other than this every code in this file is correct. What you want to do is just Add the Node class to your script...
Thank you
.