level order tree travarsel
class Node{
public:
long val = 0;
Node *left = nullptr, *right = nullptr;
Node(int val_): val(val_){}
};
void level_order_traversal(Node *root=nullptr){
// printf("Level Order Tree Traversal: \n");
if(not root) return;
queue<Node*> Q;
Q.push(root);
Q.push(nullptr);
while(Q.size() > 1){
Node *current = Q.front();
Q.pop();
if(not current){
printf("\n");
Q.push(nullptr);
continue;
}
printf("%ld ", current->val);
if(current->left) Q.push(current->left);
if(current->right) Q.push(current->right);
}
printf("\n\n");
}