You are viewing a single comment's thread. Return to all comments →
Here's my code for level order but its showing some error i couldnt find plz help
int rear=0,front=-1;
struct queue { node* value; }s[50];
int isFull() { if(rear==50) return 1; else return 0; }
int isEmpty() { if(front==-1) return 1; else return 0; }
void push(node * root) { if(!isFull()) {queue[rear].value=root; rear++;} }
node* pop() { node* temp; if(!isEmpty()) { temp=queue[front].value; front++;} return temp; }
void LevelOrder(node * root) { node* temp=root; while(temp) { printf("%d",temp->data); if(temp->left) push(temp->left); if(temp->right) push(temp->right); temp=pop(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Level Order Traversal
You are viewing a single comment's thread. Return to all comments →
Here's my code for level order but its showing some error i couldnt find plz help
int rear=0,front=-1;
struct queue { node* value; }s[50];
int isFull() { if(rear==50) return 1; else return 0; }
int isEmpty() { if(front==-1) return 1; else return 0; }
void push(node * root) { if(!isFull()) {queue[rear].value=root; rear++;} }
node* pop() { node* temp; if(!isEmpty()) { temp=queue[front].value; front++;} return temp; }
void LevelOrder(node * root) { node* temp=root; while(temp) { printf("%d",temp->data); if(temp->left) push(temp->left); if(temp->right) push(temp->right); temp=pop(); }