View Single Post
  #8 (permalink)  
Old 08-05-2007, 02:24 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,118
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Bench, truly.. I'm kind of confused with recursion method, probably I need some practice to read recursion more

can you please explain what happened to my inorder method?
Let's say the inputs are: 5, 2, 9, 1, 3, 11

PHP Code:
    public void inorder(BinaryNode node) {
        if (
node == null) {
            return;
        }
        
inorder(node.getLeft());
        
System.out.println(node.getValue()); // visit the code
        
inorder(node.getRight());
    } 
I fixed the problem already lol, just forgot return; in each of the if statement within the while loop, that causes set the number 3 both on the right side of 1 and 2

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote