树的中序遍历(非递归)
来源:互联网 发布:mm漫画软件下载 编辑:程序博客网 时间:2024/05/16 04:48
public class Solution { public List<Integer> inorderTraversal(TreeNode root) { List<Integer> list = new ArrayList<Integer>(); if (root == null) return list; Stack<TreeNode> stack = new Stack<TreeNode>(); while (root != null || !stack.empty()) { while (root != null) { stack.push(root); root = root.left; } if (!stack.empty()) { TreeNode node = stack.pop(); list.add(node.val); root = node.right; } } return list; }}
0 0
- 二叉树非递归后序遍历(非递归遍历中最麻烦的一个)
- 树的前序遍历非递归、中序遍历非递归、后序遍历非递归
- 二叉树的遍历(中序,非递归)
- 二叉树的中序遍历(非递归)
- 树的中序遍历(非递归)
- 树的中序遍历(非递归实现)
- 二叉树的中序遍历(非递归)
- 二叉树的中序递归,非递归遍历
- 二叉非递归的中序遍历(递归创建)
- 树的非递归遍历(中序遍历)
- 中序遍历二叉树(递归 & 非递归)
- 二叉树的前序遍历、中序遍历、后续遍历 (包括递归、非递归,共六种)
- 树的遍历(递归、非递归)
- 【数据结构与算法】二叉树的遍历(递归遍历、非递归遍历、层序遍历)
- 二叉树的先序/中序/后序(递归、非递归)+层序遍历
- 二叉树的遍历(2)--先序遍历,中序遍历,后序遍历(非递归)
- 二叉树的创建,遍历(前序,中序,后序)-递归 非递归
- 二叉树的前序、中序、后序(递归、非递归)遍历java实现
- Unity mesh 合并
- ocp-76
- hdu 4777
- ocp-77
- ocp-78
- 树的中序遍历(非递归)
- Linux tomcat 重启
- 值得推荐的C/C++框架和库
- 运算放大器规范总结
- 131 Palindrome Partitioning [Leetcode]
- <单调队列><二分>4.偷懒的西西
- DirectX11 兰伯特余弦定理(Lambert)
- (LeetCode) String to Integer (atoi) (Java)思路讲解及实现
- Opengl中的三维数学二(点和向量的简单运算)