Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain walter's model of dividend policy.

Answered: 1 week ago