二叉树的层序遍历(队列实现):
// 层序遍历
void LevelOrder()
{
if(_pRoot == NULL)
return;
queue<Node*> q;
q.push(_pRoot);
while(!q.empty())
{
Node* pCur = NULL;
pCur = q.front();
q.pop();
cout<<pCur->_data<<" ";
if(pCur->_pLeft)
q.push(pCur->_pLeft);
if(pCur->_pRight)
q.push(pCur->_pRight);
}
cout<<endl;
}