Question
Please help me execute the last part of my Java file. Most of it is written. The program should read expression trees and determine pre-order
Please help me execute the last part of my Java file. Most of it is written. The program should read expression trees and determine pre-order and post-order traversal. I am having issues with user input of expression trees. Please look at the bottom part of my code and help me make it run. Users should input an expression, and the program should print the expression in pre-order and post-order. It must also display the result as a tree, not just a string. Any help is greatly appreciated. here is my code.
package OperatingSystemsHW1;
import OperatingSystemsHW1.Node;
public class Node
@Override public int compareTo(Node
package OperatingSystemsHW1;
import java.util.Scanner; import java.util.Stack;
import OperatingSystemsHW1.Node;
public class TreeExercise { public static boolean isOp(String str) { if (str.equals("/") || str.equals("+") || str.equals("-") || str.equals("*")) { return true; } return false; } // Constructs expression tree public static Node
//need to make an object of an expression tree here (Don't know how)
System.out.println("Enter Expression:"); //object.conExpTree(scan.next());
System.out.print("Pre-Order Expression:"); //object.postOrderTraveral();
System.out.print("Post-Order Expression:"); //object.postOrderTraveral();
}
Step 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