摘要: 二叉树的递归遍历很容易写出来,对于递归遍历则需要借助辅助栈,并且不同的遍历次序迭代的写法也不尽相同,这里整理一些二叉树迭代遍历的实现 二叉树的前序遍历 [leetcode144]:https://leetcode cn.com/problems/binary tree preorder traver 阅读全文
posted @ 2020-02-10 23:27 patrolli 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 题目 :https://leetcode cn.com/problems/unique binary search trees ii/ 给定一个整数 n,生成所有由 1 ... n 为节点所组成的二叉搜索树。 思路 :还是要从递归的角度去思考,策略是,从1 n中选择i作为根节点,那么1 i 1作为它 阅读全文
posted @ 2020-02-10 23:08 patrolli 阅读(140) 评论(0) 推荐(0) 编辑