`

算法(二)二叉树

 
阅读更多

 

深度优先遍历二叉树:先根后根中根

        递归思想

        void XXBL(tree* root){                //先序遍历

                //Do Something with root

                if(root->lchild!=NULL) XXBL(root->lchild);

                if(root->rchild!=NULL) XXBL(root->rchild);

        }

 

        void ZXBL(tree* root){                //中序遍历

                if(root->lchild!=NULL) ZXBL(root->lchild);

                //Do Something with root

                if(root->rchild!=NULL) ZXBL(root->rchild);

 

        }

 

广度优先遍历多叉树:

 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics