foo(tree* root)
{
if(!root) return;
stl::queue
s.push(root);
while(!s.empty())
{
tree* curr=s.front();
s.pop();
if(curr->left&&curr->right)
connect curr->left to curr->right;
if(curr->left)
s.push(curr->left);
if(curr->right)
s.push(curr->right);
}
return;
}
No comments:
Post a Comment