Tree: Level Order Traversal

  • + 0 comments

    //for cpp if(root == NULL) return; queue q; q.push(root);

        while(!q.empty()){
            Node* current = q.front();
            q.pop();
            cout<<current->data<<" ";
            if(current->left!=NULL)
            q.push(current->left);
            if(current->right!=NULL)
            q.push(current->right);