Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Tree =
- | Empty
- | Node of int * Tree * Tree
- let rec insert tree v =
- match tree with
- | Node(v0, left, right) when v<v0 -> Node(v0, (insert left v), right)
- | Node(v0, left, right) when v>v0 -> Node(v0, left, (insert right v))
- | Empty -> Node(v, Empty, Empty)
- let rec printTree tree =
- match tree with
- | Empty -> ()
- | Node(v, left, right) ->
- printTree left
- printfn "%d" v
- printTree right
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement