【发布时间】:2018-09-23 22:50:11
【问题描述】:
我有使用递归按顺序(升序)打印二叉搜索树内容的代码。我知道辅助方法调用递归方法以 root 作为开始节点值。但我不明白递归代码在概念上是如何工作的。谁能解释一下?
//ascend method that prints values in the tree in ascending order
//recursive method below
public void printAscending() {
printAscending(root);
}
private void printAscending(Node node) {
if(node != null) {
printAscending(node.left);
System.out.println(node.data);
printAscending(node.right);
}
}
【问题讨论】:
-
@SebastiaanvandenBroek 请避免以后进行无意义的编辑。为一个空间编辑帖子是不值得的。
标签: java