(* functions from the lecture notes *) datatype 'a tree = Lf | Br of 'a * 'a tree * 'a tree fun count Lf = 0 | count (Br(v,t1,t2)) = 1 + count t1 + count t2 exception Missing of string fun lookup (Br ((a,x),t1,t2), b) = if b < a then lookup(t1, b) else if a < b then lookup(t2, b) else x | lookup (Lf, b) = raise Missing b fun update (Lf, b:string, y) = Br((b,y), Lf, Lf) | update (Br((a,x),t1,t2), b, y) = if b x) (preord b)) (* some trees for you to plat with *) val test1 = Lf val test2 = Br (("Alice", 6), Lf, Lf) val test3 = Br (("Gerald", 8), Br (("Alice", 6), Lf, Lf), Br (("Lucy", 9), Lf, Lf)) val test3 = Br(("Alice", 6), Lf, Br(("Tobias", 2), Br(("Gerald", 8), Lf, Br(("Lucy", 9), Lf, Lf)), Lf)) val test4 = Br (("Alice", 6), Br (("Abi", 11), Lf, Lf), Br (("Tobias", 2), Br (("Gerald", 8), Lf, Br (("Lucy", 9), Lf, Lf)), Lf))