Advertisement
Guest User

Untitled

a guest
May 29th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.79 KB | None | 0 0
  1.     let rec removeNode e = function
  2.      | Lf               -> Lf
  3.      | Br (v, t1, t2)   -> if (funcID (<) (e,v)) then (Br(v, removeNode e t1, t2))
  4.                            elif (funcID (>) (e,v)) then (Br(v, t1, removeNode e t2))
  5.                            else match (t1, t2) with
  6.                                  | (Lf, Lf)                                -> Lf
  7.                                  | (Br(v1, t11, t21), Lf)                  -> Br (v1, t11, t21)
  8.                                  | (Lf, Br(v2, t12, t22))                  -> Br (v2, t12, t22)
  9.                                  | (Br(v1, t11, t21), Br(v2, t12, t22))    -> let (min, newTree) = removeMinNode (Br(v2, t12, t22))
  10.                                                                               Br (min, Br(v1, t11, t21), newTree)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement