You are viewing a single comment's thread. Return to all comments →
void levelOrder(Node * root) { queue<Node*>q; q.push(root); while(!q.empty()){ int size = q.size(); for(int i=0;i<size;i++){ Node* popnode=q.front(); q.pop(); cout<<popnode->data<<" "; if(popnode->left!=NULL){ q.push(popnode->left); } if(popnode->right!=NULL){ q.push(popnode->right); } } } }
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 →