二叉树的先序,后序,层 的非递归遍历 void iter_preorder(BTree *p)//////先序非递归遍历{ BTree *stack[MaxLen]; int top=0;/////记录栈的头 while(p!=NULL || top>0) { while(p!=NULL)/////这个while循环是为了将树的左边的元素全部一次进栈 { coutdata stack[t null 2024-05-15 192 点赞 2 评论 290 浏览
[LeetCode]145 二叉树后序遍历 Binary Tree Postorder Traversal(二叉树后序遍历)【难度:Medium】 Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [3,2,1].Note: Recursiv LeetCode 2024-05-15 175 点赞 2 评论 265 浏览