如何为我的二叉树实现编写正确的中序方法?
这是我的测试:
class Main {
public static void main(String[] args) {
BinaryTree myTree = new BinaryTree();
myTree.inorder(0);
}
}
public class BinaryTree {
char[] tree = {'k', 'q', 'r', 'g', 'e', 'i', 'y', 'p', 'l', 'b', 'x', 'm', 'g', 't', 'u', 'v', 'z'};
public void inorder(int node) {
if(node < tree.length) {
inorder((node * 2));
System.out.print(tree[node] + " ");
inorder(((node * 2) + 1));
}
}
}