码迷,mamicode.com
首页 > 其他好文 > 详细

binary search tree Traversal

时间:2015-03-27 23:44:52      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

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  }

 

binary search tree Traversal

标签:

原文地址:http://www.cnblogs.com/luochuanghero/p/4372975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!