943,871 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1314
  • Java RSS
Feb 23rd, 2009
0

How to traverse

Expand Post »
Java Syntax (Toggle Plain Text)
  1.  
  2. public String preOrder(int nodeIndex) {
  3. if(nodeIndex>nodeArray.length) {
  4. return(null);
  5. } else if(nodeArray[nodeIndex].isLeaf(nodeArray.length-1)) {
  6. return(nodeArray[nodeIndex].toString());
  7. } else {
  8. return(nodeArray[nodeIndex].toString()+" "+preOrder(nodeArray[nodeIndex].leftChild)+" "+preOrder(nodeArray[nodeIndex].rightChild));
  9. }

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.
}
Similar Threads
Reputation Points: 5
Solved Threads: 0
Light Poster
l_03 is offline Offline
37 posts
since Oct 2008
Feb 23rd, 2009
0

Re: How to traverse

what you have there doesn't explain a whole lot...
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Java question...
Next Thread in Java Forum Timeline: JAVA SQL matrix





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC