class BTreeArray{
int MaxSize=16;
int[] ABTree=new int[MaxSize];
public BTreeArray()
{
for(int i=0;i<MaxSize;i++)
{ABTree[i]=0;}
}
//----------------------------
//建立二叉树
//----------------------------
public void Create(int data)
{
int Level=1;//树的阶层数,从1开始;1实质上就是根接点的阶层数
while(ABTree[Level]!=0)//判断是否有子树存在;即找叶子接点
{
if(Data<ABTress[Level])
Level=Level*2;
else
Level=Level*2+;
}
ABTree[Level]=data;
}
//---------------------------
//打印所有二叉树的接点数据
//---------------------------
public void printAll()
{
System.out.println("all treenode:");
for(int i=1;i<MaxSize;i++)
{System.out.print("Node"+i);
System.out.println(":["+ABTress[i]+"]");
}
}
}
int MaxSize=16;
int[] ABTree=new int[MaxSize];
public BTreeArray()
{
for(int i=0;i<MaxSize;i++)
{ABTree[i]=0;}
}
//----------------------------
//建立二叉树
//----------------------------
public void Create(int data)
{
int Level=1;//树的阶层数,从1开始;1实质上就是根接点的阶层数
while(ABTree[Level]!=0)//判断是否有子树存在;即找叶子接点
{
if(Data<ABTress[Level])
Level=Level*2;
else
Level=Level*2+;
}
ABTree[Level]=data;
}
//---------------------------
//打印所有二叉树的接点数据
//---------------------------
public void printAll()
{
System.out.println("all treenode:");
for(int i=1;i<MaxSize;i++)
{System.out.print("Node"+i);
System.out.println(":["+ABTress[i]+"]");
}
}
}