package treeTest;
import java.util.Stack;
public class BinaryTree2 {
public class TreeNode{
private int index;
private String date;
private TreeNode leftChild;
private TreeNode rightCHild;
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public TreeNode(int index, String date){
this.index = index;
this.date = date;
this.leftChild = null;
this.rightCHild = null;
}
}
private TreeNode root = null;
public BinaryTree2(){
root = new TreeNode(1,"A");
}
/**
* 创建树
* */
public void createBinaryTree(){
TreeNode nodeB = new TreeNode(2,"B");
TreeNode nodeC = new TreeNode(3,"C");
TreeNode nodeD = new TreeNode(4,"D");
TreeNode nodeE = new TreeNode(5,&#
java 创建二叉树 前序、中序、后续 递归遍历树 和 非递归遍历,递归求树高,递归求树节点数
最新推荐文章于 2024-04-20 01:51:27 发布