void LevelOrderTraversal(BinTree BT)
{
if (!BT)
return;
queue<BinTree> Q;
Q.push(BT);
BinTree tmp=BT;
while (!Q.empty())
{
tmp = Q.front();
Q.pop();
printf("%c", tmp->Data);
if (tmp->Left)
Q.push(tmp->Left);
if (tmp->Right)
Q.push(tmp->Right);
}
}
二叉树的层次遍历
最新推荐文章于 2023-07-05 21:27:44 发布