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. 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

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

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions

Question

Discuss about training and development in India?

Answered: 1 week ago

Question

Explain the various techniques of training and development.

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago

Question

1. Why do people tell lies on their CVs?

Answered: 1 week ago

Question

2. What is the difference between an embellishment and a lie?

Answered: 1 week ago