Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > level order tra...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 24581 of 28006
Post > Topic >>

level order traversal of binary tree

by sophia.agnes@[EMAIL PROTECTED] Feb 14, 2008 at 06:01 AM

Dear all,

How good is this function which implements level order traversal of
binary tree ?

level_trav(struct node *sn)
{
  struct node *queue[MAX];
  int front = rear = -1;

  front++;
  rear++;
  queue[rear] = sn;

  while(front <= rear)
  {
     sn = queue[front++];
     if(sn != NULL)
     {
       printf("%d",sn -> val);
       queue[++rear] = sn -> left;
       queue[++rear] = sn -> right;
     }
   }
 }
 




 5 Posts in Topic:
level order traversal of binary tree
sophia.agnes@[EMAIL PROTE  2008-02-14 06:01:40 
Re: level order traversal of binary tree
Ben Bacarisse <ben.use  2008-02-14 15:44:37 
Re: level order traversal of binary tree
Kaz Kylheku <kkylheku@  2008-02-14 22:39:08 
Re: level order traversal of binary tree
Kaz Kylheku <kkylheku@  2008-02-14 23:10:19 
Re: level order traversal of binary tree
Barry Schwarz <schwarz  2008-02-14 17:54:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 12:59:23 CST 2008.