954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to traverse

public String preOrder(int nodeIndex) {
if(nodeIndex>nodeArray.length) {
return(null);
} else if(nodeArray[nodeIndex].isLeaf(nodeArray.length-1)) {
return(nodeArray[nodeIndex].toString());
} else {
return(nodeArray[nodeIndex].toString()+" "+preOrder(nodeArray[nodeIndex].leftChild)+" "+preOrder(nodeArray[nodeIndex].rightChild));
}


I am really stack with it. I dont how to output the numbers i input. If i input: 1 2 3 4 5 6, it only outputs 1 2 3. Please help me, I really need your help. Thank you in advance. We have to use arrays.
}

l_03
Light Poster
37 posts since Oct 2008
Reputation Points: 5
Solved Threads: 0
 

what you have there doesn't explain a whole lot...

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You