Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

level order traversal of binary tree

How good is this function which implements level order traversal of

binary tree?

I got this code from a question on this problem post.

level_trav(struct node *sn)


struct node *queue[MAX];

int front = rear = -1;



queue[rear] = sn;

while(front <= rear)


sn = queue[front++];

if(sn != NULL)


printf("%d",sn -> val);

queue[++rear] = sn -> left;

queue[++rear] = sn -> right;




Sign In or Register to comment.