Question
I need a little help answering this question! This is the code for expression tree which needs to be implemented in order to solve this
I need a little help answering this question!
This is the code for expression tree which needs to be implemented in order to solve this problem
import javax.swing.JOptionPane;
import java.util.*; import java.io.*;
public class ExpressionTree { private Node
public ExpressionTree (){ root = null; }
private ExpressionTree (Node
public ExpressionTree (String data, ExpressionTree leftT, ExpressionTree rightT){ root = new Node
private static class Node
private Node(E item){ data = item; left = null; right = null; }
private Node(E item, Node
} //end of private class }
1. Implement the class ExpressionTree to support the execution of the following program public class ExpTest i public static void main(String args[) Expres 10nTree a = new ExpressionTree (); a.initialization); System.out.println (a) System.out.println(a.cal()); When the input of the expression is "3 * ( 2 + 4 )-4 / 2 " the print out will be: JGRASP exec: java Exprest null null null null null null null null null null 0.20000000000000018 JGRASP: operation complete You can also test the program with the expression "9/3* (2 * 3 +4-2 * 3) / 2 - 4 / 2." We assume that the number is always double type and contains the decimal part. As required, you need to realize the input of an infix expression inside of the method "initialization," the display of the entire tree in the infix travel manner in "toString," and the calculation of the entire tree with the method "cal." 1. Implement the class ExpressionTree to support the execution of the following program public class ExpTest i public static void main(String args[) Expres 10nTree a = new ExpressionTree (); a.initialization); System.out.println (a) System.out.println(a.cal()); When the input of the expression is "3 * ( 2 + 4 )-4 / 2 " the print out will be: JGRASP exec: java Exprest null null null null null null null null null null 0.20000000000000018 JGRASP: operation complete You can also test the program with the expression "9/3* (2 * 3 +4-2 * 3) / 2 - 4 / 2." We assume that the number is always double type and contains the decimal part. As required, you need to realize the input of an infix expression inside of the method "initialization," the display of the entire tree in the infix travel manner in "toString," and the calculation of the entire tree with the method "calStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started