标签:
Traversal Examples
A Pre-order(根结点-左孩子-右孩子) traversal visits nodes in the following order:
25, 15, 10, 4, 12, 22, 18, 24, 50, 35, 31, 44, 70, 66, 90
InOrder(左孩子-根结点-右孩子) visits nodes in the following order:
4, 10, 12, 15, 18, 22, 24, 25, 31, 35, 44, 50, 66, 70, 90
A Post-order(左孩子-右孩子-根结点) traversal visits nodes in the following order:
4, 12, 10, 18, 24, 22, 15, 31, 44, 35, 66, 90, 70, 50, 25
1 /*Definition for binary tree*/ 2 public class TreeNode { 3 int val; 4 TreeNode left; 5 TreeNode right; 6 TreeNode(int x) { val = x; } 7 }
标签:
原文地址:http://www.cnblogs.com/luochuanghero/p/4372975.html