I want to traverse the binary tree breadth-first
where traverse_tree is a queue<Node*>. I thought this will give me breadth first traversal, but it turned out to be depth-first because of the way I recurse. Is there another way to organize this to obtain level-order?Code:void Tree::bf_traverse() { qu_node(root); } void Tree::qu_node( Tree::Node* node) { traverse_tree.push(node); if(node->relate[1] != NULL) { qu_node(node->relate[1]); } if(node->relate[2] != NULL) qu_node(node->relate[2]); }