package pro3;
import java.util.Scanner;
import pro3.util.BinTreeJFrame;
import pro3.util.BinTreeJFrame.IDrawNode;
public class BinSearchTree {
public static void main(String[] args) {
BinSearchTree t = new BinSearchTree();
}
// Node root;
public BinSearchTree() {
nil = new Node(-1);
nil.p = nil;
nil.r = nil;
nil.l = nil;
int data[] = new int[]{70,50,90,20,60,80,120,10,30,110,130,0,40,100,140};
for (int i = 0; i < data.length; i++) {
insert(data[i]);
}
BinTreeJFrame j = new BinTreeJFrame(nil.r,”1”);
Scanner sc = new Scanner(System.in);
int count=0;
while(true){
int a = sc.nextInt();
delete(a);
j = new BinTreeJFrame(nil.r,”remove=”+a);
// j.update();
System.out.println(count++);
}
// System.out.println(“max=”+max().id+”, min=”+min().id+” ,pre=”+pre(search(1)).id+” ,post=”+post(search(1)).id);
// System.out.println();
}
void insert(int id){
Node curr = nil.r;
Node p = nil;
while(curr!=nil){
p = curr;
if(id