packagecom.example.demo.tree;importcom.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;importorg.omg.PortableInterceptor.INACTIVE;importjava.util.Comparator;/***@authorsteve
* @date 2020/4/16 10:03 上午*/
public class BinaryTree{private intsize;public Noderoot;private Comparatorcomparator;public BinaryTree(Comparatorcomparator){this.comparator =comparator;
}publicBinaryTree(){this(null);
}public voidadd(E element){if (root == null){
Node node= newNode(element);
root=node;
}else{
Node parent =root;
Node node =root;int com = 0;while (node != null){
parent=node;if (comparator == null){
com=((Comparable)node.element).compareTo(element);
}else{
System.out.println("-------------");
com=comparator.compare(node.element,ele