That's a breadth first search. The only gotcha is that the usage of
push and pop maybe misleading (implying that we're using stack). But
actually it should use FIFO. You should view each push as enqueue and
pop as dequeue. It will traverse the tree layer by layer, left to
right.
On 3/24/07, vim
On Mar 23, 8:17 am, "tuesday" <[EMAIL PROTECTED]> wrote:
> u can use a queen in bfs traverse
>
> void visit(Node* r)
> {
>
> }
>
> void BF_Traverse(Node* r)
> {
>queen q;
>q.push(r);
>while(!q.empty())
>{
> Node* t = *q.front();
> q.pop();
> visit(t)
u can use a queen in bfs traverse
void visit(Node* r)
{
}
void BF_Traverse(Node* r)
{
queen q;
q.push(r);
while(!q.empty())
{
Node* t = *q.front();
q.pop();
visit(t);
if(t->left !=0)
q.push(t->left);
if(t->right!=0)