The thing that you asked for is formally known as BFT (Breadth First
Traversal). Here's the pseudo-code that'll give you the idea in
general.
#define MAX 100
void BFT ( node *root )
{
node *p;
ins_Q(root); // inserting the node into a queue
do
{
p = del_Q(); // deleting an item from the queue
visit(p);
if ( p->left != NULL )
ins_Q(p->left);
if ( p->right != NULL )
ins_Q(p->right);
} while ( <queue is not empty> );
}
This will cause the traversal from left to right in each level.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---