File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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()
 
Consider Paul's rocket mass heater.
 
subject: Breadth-first traversal