Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pls quick sorry programming language is ocaml Define a function sum_list_tree of type int list tree -> int in hw4_trees.ml such that sum_list_tree t returns

image text in transcribed

pls quick

sorry programming language is ocaml

Define a function sum_list_tree of type int list tree -> int in hw4_trees.ml such that sum_list_tree t returns the summation of all numbers in the tree t. The function is similar to sum_tree mentioned in the lectures except that each element is now a list of numbers instead of just one single number. If there are no numbers in the tree t, possibly because all elements are the empty list, then the function should return the zero. For example, sum_list_tree Leaf ===> 0 sum_list_tree (Branch (Leaf, [], Leaf)) ===> 0 sum_list_tree (Branch (Leaf, [100], Leaf)) ===> 100 sum_list_tree (Branch (Leaf, (1;2), Branch (Branch (Leaf, [], Leaf), [3; 4), Branch (Leaf, [5], Leaf)))) ===> 15 Again, add the rec keyword to the binding if you want to

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

Students also viewed these Databases questions