二叉树的先序、中序、后序非递归遍历算法
记录一下二叉树的先序、中序、后序非递归遍历算法因为递归算法很简单,所以不再罗列节点的结构体定义为:typedef struct BTNode{ int val; struct BTNode* left; struct BTNode* right;}BTNode;访问节点的函数:void visit(BTNode* p){ printf("%d\n", p->val);}1.先序非递归void pre_order(BTNode* root){ if(root == NUL
原创
2020-09-27 18:02:40 ·
688 阅读 ·
0 评论