This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Breadth-first traversal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Breadth-first traversal" Watch "Breadth-first traversal" New topic
Author

Breadth-first traversal

Mark Rem
Greenhorn

Joined: Dec 11, 2004
Posts: 13
I'm trying to implement a Breadth-first traversal in the application class use a queue and a binarysearchtree..I'm getting an error

public void breadthFirst( TreeNode tNode)
{
Queue q = new Queue( );
if( q.isEmpty() )
{
q.enqueue( this );
}

while( !q.isEmpty() )
{

}

}

E:\ICS\ICS 211 Projects (Fall 04)\Final Exam\211final_src\FinalDataTypesTest.java:11: cannot resolve symbol
symbol : class TreeNode
location: class FinalDataTypesTest
public void breadthFirst( TreeNode tNode)
^
1 error
Amirthalingam Prasanna
Ranch Hand

Joined: Jan 08, 2004
Posts: 107
Hi,
Its because your method cannot find the class TreeNode.
If you are using the TreeNode from the swing library you need to import javax.swing.tree.TreeNode to make it work


Prasanna <br />[SCJA Beta, SCJP 1.4, SCJP 5.0 Beta]<br />[MCSD, MCPD, MCT, MVP]<br /><a href="http://www.prasanna.ws" target="_blank" rel="nofollow">My Blog</a>
Mark Rem
Greenhorn

Joined: Dec 11, 2004
Posts: 13
what about if my TreeNode class is in my BinarySearchTree class?
How can pass it as a parameter to the breadthFirst()
 
 
subject: Breadth-first traversal
 
Similar Threads
Fail to create generic array?
Question about TreeNode
add method in a tree class
how to set a node on expression tree
Help with expression Tree