template<class T>//层序遍历
void Level(BTNode<T>* t)
{
if(!t)//
return;
queue<BTNode<T>*> q;
q.push(t);
while(!q.empty())
{
BTNode<T>* a;
a=q.front();
q.pop();
cout<<a->data;
if(a->left)
q.push(a->left);
if(a->right)
q.push(a->right);
}
}
二叉树的层序遍历
最新推荐文章于 2023-10-06 09:34:51 发布