Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-03-2007, 09:06 PM
Member
 
Join Date: Dec 2007
Posts: 4
tuckker is on a distinguished road
Preorder Traversal problem...
I have:


Code:
public void preOrderTrav() { CustNode current = root; Tree t; printCustNode(current); System.out.println(current.key + "," + current.name); for (int i = 0; i < current.rentVid.size(); i++) { //Loop to add all videos in each node System.out.print("," + current.rentVid.get(i)); if (current.left != null) current.left.preOrderTrav(); } }
HOwever obviously current.left.preOrderTrav(); won't work, since the above code is in a Tree.java.

How do I do an iterative of preOrderTrav() on the left Node?

FYI:

Code:
class CustNode { int key; //Which is also the tel No since tel no is unique String name; Vector rentVid = new Vector(); CustNode left; CustNode right; }
This method is in the Tree.java. Other than this method, this Tree.java contains other methods which includes the insert, delete, findNode methods etc...

Let me know if more info is needed
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-03-2007, 10:20 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
public String getPreOrderSort() { String s = ""; s += name + " "; if(left != null) s += left.getPreOrderSort() + " "; if(right != null) s += right.getPreOrderSort() + " "; return s; }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-04-2007, 03:27 AM
Member
 
Join Date: Dec 2007
Posts: 4
tuckker is on a distinguished road
Where should that be? inthe node class file or in the tree class file?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-04-2007, 07:06 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Try it in your CustNode class. Call it on the root (or any) node in your Tree class.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bidirectional Traversal with ListIterator Java Tip java.lang 0 04-16-2008 11:37 PM
JTable Focus Traversal helios_lie AWT / Swing 1 12-20-2007 11:27 AM
Array traversal issues sondratheloser New To Java 1 12-11-2007 08:55 PM


All times are GMT +3. The time now is 09:42 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org