class IntSet16 { // Destructive Set class, sets stored as ordered trees // Recursive methods used private Cell tree; public void delete(int n) { if(tree!=null) if(tree.left==null&&tree.right==null) { if(tree.item==n) tree=null; } else delete(n,tree); } private static void delete(int n,Cell t) { if(nt.item) if(t.right.left==null&&t.right.right==null) { if(t.right.item==n) t.right=null; } else delete(n,t.right); else if(t.left==null) { t.item=t.right.item; t.right=t.right.right; } else if(t.left.right==null) { t.item=t.left.item; t.left=t.left.left; } else t.item = removeRightmost(t.left); } private static int removeRightmost(Cell t) { if(t.right.right==null) { int rightmost = t.right.item; t.right = t.right.left; return rightmost; } else return removeRightmost(t.right); } public void add(int n) { if(tree==null) tree = new Cell(n,null,null); else add(n,tree); } private static void add(int n,Cell t) { if(nt.item) if(t.right==null) t.right = new Cell(n,null,null); else add(n,t.right); } public boolean member(int n) { return member(n,tree); } private static boolean member(int n,Cell t) { if(t==null) return false; else if(t.item==n) return true; else if(n