首页 > 代码库 > Java创建二叉树

Java创建二叉树

二叉树的值保存在数组中,以0作为分隔,数字0表示空节点,数组

public static final int[] TREE_VALUE = http://www.mamicode.com/new int[]{1,2,3,0,4,5,0,0,6,0,0,7,0,0,8,0,9,10,0,0,0};
表示的二叉树是:


/**
 * 维护构建二叉树的值和值索引
 */
public static class TreeValue {
	public static int index = 0;
	public static final int[] TREE_VALUE = http://www.mamicode.com/new int[]{1,2,3,0,4,5,0,0,6,0,0,7,0,0,8,0,9,10,0,0,0};>