Glad you got it working.
Type: Posts; User: Norm
Glad you got it working.
It needs to use the returned value.
What does the debugging output show?
Why isn't the value returned by inorderHelper() used????
Can you explain why there are three double args to the method? The code only needs to have the current max to compare against.
The method should ALWAYS return the max found so far. Never 0!!!
How about another arg for the method: currMax
You need to have the current max value available as you transit the tree so you can test if the current node's value is bigger.
Save what the method returns in a variable.
The inorderHelper() method looks like its a start in the right direction.
Some comments:
1)What are the x,y variables for? x,y would look like a position in a 2D graph not part of a search for a...
Here's what prints out with:
System.out.println(root);
when there is a toString() method in the Node class.
{ S=Hyena, d=0.53, l={ S=Hamster, d=0.29, l={ S=Beetle, d=1.04, l={...
Please post the debug output on the forum.
I don't see the toString() method in the Node class.
The printlns generate too many lines of output. x and y could be printed on the same line.
...
I don't see any debugging output when the program executes. All it prints is: 1.04
For testing I'd make as small a tree as possible to keep the debug print out down.
Which post is the code in? Posts are numbered in upper right. This is post #19
Please post code for testing that will compile, execute and show the problem. What you posted won't compile.
Do you have code that will compile, execute and show what you are talking about?
The two suggestions go together. By adding a toString() method to the Node class and then printing root( a Node) the compiler will generate calls to the Node class's toString() method that will...
It would have to look at all the nodes.
You don't need another file for testing. You need to verify that the file you posted shows the error,
If the code only looks on one side of the tree, how will it find something that could be on...
If you have not used the file and proved that it causes the error, then it is a waste of time for me to use it. You need to post data that causes the error.
What's in the file it ties to read?
I'm done for tonight, back tomorrow.
How can we test the code to see how it works?