您的位置:首页 > 其它

LeetCode -- Binary Tree Inorder Traversal

2015-09-19 16:10 369 查看
本题就是树的中序遍历过程。

实现代码:

/**
* Definition for a binary tree node.
* public class TreeNode {
*     public int val;
*     public TreeNode left;
*     public TreeNode right;
*     public TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public IList<int> InorderTraversal(TreeNode root)
{
Travel(root);
return result;
}
private void Travel(TreeNode node){

if(node == null){
return ;
}

Travel(node.left);
result.Add(node.val);
Travel(node.right);
}

private IList<int> result = new List<int>();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: