给定一个二叉树,返回其中序遍历.例如:给定二叉树 [1,null,2,3], 1 \ 2 / 3返回 [1,3,2].说明: 递归算法很简单,你可以通过迭代算法完成吗?详见:https://leetcode.com/problems/binary-tree-inorder-traversal/description/ Java实现: 递归实现: /** * Definition for a binary tree node. * public class TreeNo…
既上篇关于二叉搜索树的文章后,这篇文章介绍一种针对二叉树的新的中序遍历方式,它的特点是不需要递归或者使用栈,而是纯粹使用循环的方式,完成中序遍历. 线索二叉树介绍 首先我们引入“线索二叉树”的概念: "A binary tree is threaded by making all right child pointers that would normally be null point to the inorder successor of the node, and all left chi…
Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2]. Note: Recursive solution is trivial, could you do it iteratively? co…