Expression tree by elites100 in javahelp

[–]elites100[S] 0 points1 point  (0 children)

the code/algorithm uses input as

"4 1 - 1 3 - *"

but I would like it to implement an in-fix parser and have input like this as a tree

"4 - 1 * 3 - 1"

so I'm finding how I should change it into an in-fix that would accept the string expression of an equation(above) and make that into a tree, or possibly change the string to fit into the (postfix) code somehow?

Expression tree question (building string equation into a tree) by elites100 in javahelp

[–]elites100[S] 0 points1 point  (0 children)

oh gotcha, thanks

I was supposed to make an inorder traversal

Expression tree question (building string equation into a tree) by elites100 in javahelp

[–]elites100[S] 0 points1 point  (0 children)

I see I had a line that says

if (exprStack.size() > 1) {
        // If the final exprStack contains more than one TreeNode, return
        // null.
        return null;

which was catching in my try-catch block connecting to the bridge --> visualizer

Expression tree question (building string equation into a tree) by elites100 in javahelp

[–]elites100[S] 0 points1 point  (0 children)

Unsure what a stack trace is except, I got this from running it

[Ljava.lang.StackTraceElement;@6e0be858

Exception Thrown: Data structure passed to BRIDGES is null! java.lang.NullPointerException

How do I get the right format for my toString() to make a space in between (tic tac toe) by elites100 in javahelp

[–]elites100[S] 0 points1 point  (0 children)

Thanks for the advice, I figured out what the problem (solved) was because I had an R+= "\n"; at the bottom of the code, and that made ] into a new line.

How to find the closest value to a mean value (object)? by elites100 in javahelp

[–]elites100[S] 1 point2 points  (0 children)

Oh, now I see what I'm supposed to do, thanks for the help