二叉树遍历结果返回一个串

方法inorderDisplay()返回一个串,这个串提供节点值的中序列表:

1 public static<T> String inorderDisplay(TNode<T> t){
2         String s = "";
3         if( t != null){
4             s += inorderDisplay(t.left);
5             s += t.nodeValue + " ";
6             s += inorderDisplay(t.right);
7         }
8         return s;
9     }

 

posted @ 2013-12-17 21:06  soul390  阅读(164)  评论(0编辑  收藏  举报