Question
Here listed above is my question above and example of how it would be done is below. I need this coded in Java as an example. This is a warm up for me to understand the project I will be diving in. The code should be fairly simple but I just do not understand it.
Edit* ignore the polish notation comment I want the output to be like I had noted below.
Thank You
strin with parenthes exatly see, of operntien The loye should follow a ree here each ope for Ly node and the last operat becomes the nestiny nele (2 The output wouw be apoloh nstat induding parenthe of the Hirst sub operation output (I 2) 3 x 4 other exam Iti tr all addutin ope it would be ktt (It) t2 :s what t become I need to do thi) in Suva where the lon an follons tree as shown above a and
Explanation / Answer
//ExpressionValidate.java import java.util.Stack; public class ExpressionValidate { public static String validateExpression(String expr) { char r[] = expr.toCharArray(); char s[] = expr.toCharArray(); Stack st = new Stack(); int i = 0; while (i 0) { System.out.println("Something is wrong!!"); } else if (s[i - 1] != ')' && top > 0) st.pop(); i++; } } StringBuffer result = new StringBuffer(); for (i = 0; i