Print and search a binary tree?

I have defined a tree like this:

type 'a btree =
| EmptyTree
| Node of ('a * 'a btree * 'a btree)

I am trying to define two functions, one that prints out every element of a tree. How do I do that when the tree can be a tree of ints but also something else like strings.

I also want to make a function that searches the tree for a specific value. Can anyone help me explain how to do this.

(* val print_tree: ('a -> unit) -> 'a btree -> unit )
val search_tree: 'a -> 'a btree -> bool *)

For the print function, you might think about what the first parameter (of type 'a -> unit) is for.

For the search function, it would be best if you had a specific question. It would take the fun out of the assignment if somebody else just wrote the code for you.


I strongly agree with that.