You are viewing a single comment's thread. Return to all comments →
Here's simplest C++ solution I could write
#include<queue> void LevelOrder(node * root) { queue<node*> q; node *temp = root; while(temp!=NULL) { cout<<temp->data<<" "; if(temp->left!=NULL) q.push(temp->left); if(temp->right!=NULL) q.push(temp->right); temp = q.front(); q.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 simplest C++ solution I could write