class IntSet18 { // Constructive Set class, sets stored as ordered trees private Cell tree; public IntSet18() { tree=null; } private IntSet18(Cell t) { tree=t; } public IntSet18 delete(int n) { return new IntSet18(delete(n,tree)); } private static Cell delete(int n,Cell t) { if(t==null) return null; else if(nt.item) return new Cell(t.item,t.left,delete(n,t.right)); else if(t.left==null) return t.right; else if(t.right==null) return t.left; else { int m=rightmost(t.left); Cell newleft=removeRightmost(t.left); return new Cell(m,newleft,t.right); } } private static int rightmost(Cell t) { if(t.right==null) return t.item; else return rightmost(t.right); } private static Cell removeRightmost(Cell t) { if(t.right==null) return t.left; else return new Cell(t.item,t.left,removeRightmost(t.right)); } public IntSet18 add(int n) { return new IntSet18(add(n,tree)); } private static Cell add(int n,Cell t) { if(t==null) return new Cell(n,null,null); else if(n==t.item) return t; else if(n