Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Breadth-first traversal

 
Mark Rem
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Rem
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about if my TreeNode class is in my BinarySearchTree class?
How can pass it as a parameter to the breadthFirst()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic