Home > Back-end >  Java environment is configured correctly why there will be such a question? A great god for help
Java environment is configured correctly why there will be such a question? A great god for help

Time:09-23

Public class BiTree {

Private BiTreeNode root;

Public BiTree () {
This. The root=null;
}

Public BiTree (BiTreeNode root) {
This. The root=root;
}

Public BiTree (String postOrder, String inOrder, int postIndex, int inIndex, int count) {
If (count & gt; 0 {
Char r=postOrder. CharAt (postIndex);
int i=0;
for (; i If (r==inOrder. CharAt (I + inIndex))
break;

The root=new BiTreeNode (r);
Root. SetLchild (new BiTree (inIndex postOrder, inOrder, postIndex + 1, I). The root).
Root. SetRchild (new BiTree (postOrder, inOrder to postIndex + I + 1,
InIndex + I + 1, the count - I - 1). The root);
}
}



//to the root of traversing binary tree recursive algorithm
Public void preRootTraverse (BiTreeNode T) {
If (T!=null) {
System. The out. Print (T.g etData ());
PreRootTraverse (T.g etLchild ());
PreRootTraverse (T.g etRchild ());
}

}



//in the recursive algorithm of traversing binary tree root
Public void inRootTraverse (BiTreeNode T) {
If (T!=null) {
InRootTraverse (T.g etLchild ());
System. The out. Print (T.g etData ());
InRootTraverse (T.g etRchild ());
}

}


//after the recursive algorithm of traversing binary tree root
Public void postRootTraverse (BiTreeNode T) {
If (T!=null) {
PostRootTraverse (T.g etLchild ());
PostRootTraverse (T.g etRchild ());
System. The out. Print (T.g etData ());
}
}


//sequence traversal of binary tree algorithm
Public void levelTraverse () {
BiTreeNode T=root;
If (T!=null) {
LinkQueue L=new LinkQueue ();
L.o ffer (T);
While (! L.i sEmpty ()) {
T=(BiTreeNode) L.p oll ();
System. The out. Print (T.g etData ());
If (T.g etLchild ()!=null)
L.o ffer (T.g etLchild ());
If (T.g etRchild ()!=null)
L.o ffer (T.g etRchild ());
}
}
}

Public BiTreeNode getRoot () {
return root;
}

Public void setRoot (BiTreeNode root) {
This. The root=root;
}
}




CodePudding user response:

CodePudding user response:

And environment, it doesn't matter, it felt like find LinkQueue this class

CodePudding user response:

The javac XXXX. Java is removed

CodePudding user response:

reference smelly boy handsome reply: 3/f
javac XXXX. Java remove

Javac XXXX. Java remove

Wrong wrong wrong, I can't see your code inside the main function of the entrance
  • Related