请你实现二叉树的层序遍历并输出

参考回答:

void layerTrace(BTreeNode *T)
{
if(T== nullptr)return;
BTreeNode *p=T;
queueq;
q.push(p);
while(!q.empty())
{
p=q.front();
q.pop();
cout<<<data;
if(p->left!= nullptr)q.push(p->left);
if(p->right!= nullptr)q.push(p->right);
}
}```

你可能感兴趣的:(请你实现二叉树的层序遍历并输出)