Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started