Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please explain on how to do this problem Given the following ML declarations of a binary tree type with integers in the leaf nodes and

image text in transcribed

please explain on how to do this problem

Given the following ML declarations of a binary tree type with integers in the leaf nodes and of five functions operating on trees: datatype tree -L of int leaf with an integer ) | N of tree treenode with two subtrees ) fun max (n, m) =if n > m then n else m fun a (L i) fun b (L i) lb(N(1, r))=max (b 1, b r) fun c (L i) fun d (L i) Id(N(1, r)) 1 + d 1 + d r fun e (L i) le(N(1, r))=1+max (e 1, e r) In each function definition, the first line is the case for a leaf node (i.e., the base case of the recursion), and the second line recursively calls the function for the left and right subtrees These functions compute the height of the tree, and the number of leaves in the tree, the sum of all the values in the leaves. the number of interior nodes in the tree, the maximum value of any leaf node in the tree Associate the functions with their descriptions. Try it first without typing them in

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

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions