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