标签:ar os sp bs ef 算法 nbsp return br
struct BinaryTreeNode
{
int m_nValue;
BinaryTreeNode *m_pLeft;
BinaryTreeNode *m_pRight;
};
//递归实现二叉树的遍历。递归算法比较简洁易懂这一就不做解释
void Preorder(BinaryTreeNode *pRoot)
{
if (pRoot == NULL)
{
return;
}
cout<<pRoot->m_nValue<<endl;
Preorder(pRoot->m_pLeft);
Preorder(pRoot->m_pRight);
}
void Inorder(BinaryTreeNode *pRoot)
{
if (pRoot == NULL)
{
return;
}
Inorder(pRoot->m_pLeft);
cout<<pRoot->m_nValue<<endl;
Inorder(pRoot->m_pRight);
}
void Postorder(BinaryTreeNode *pRoot)
{
if (pRoot == NULL)
{
return;
}
Postorder(pRoot->m_pLeft);
Postorder(pRoot->m_pRight);
cout<<pRoot->m_nValue<<endl;
}
//非递归遍历的实现。。。。。。。。。未完待续
标签:ar os sp bs ef 算法 nbsp return br
原文地址:http://www.cnblogs.com/Mr-Zhong/p/4120363.html