Question: Programming language: OCaml Write a recursive function tree_depth to compute the depth of a binary tree. The depth of an empty tree should be 0.

Programming language: OCaml

Write a recursive function tree_depth to compute the depth of a binary tree. The depth of an empty tree should be 0.

The depth of our tree should be 1, and in general, the depth of a tree is one greater than the maximum depth of the children.

For both functions, use pattern matching to name sub-parts of the arguments, and operate on the sub-parts. The code needs to start like this: type binarytree = EmptyTree | TreeNode of int * binarytree * binarytree ;; let tree = TreeNode( 3, EmptyTree, EmptyTree);;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!