How to traverse

Reply

Join Date: Oct 2008
Posts: 37
Reputation: l_03 has a little shameless behaviour in the past 
Solved Threads: 0
l_03 l_03 is offline Offline
Light Poster

How to traverse

 
0
  #1
Feb 23rd, 2009
  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.
}
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: How to traverse

 
0
  #2
Feb 23rd, 2009
what you have there doesn't explain a whole lot...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC