Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write haskell code for the following Exercise 3. Binary trees 16+5 = 21 points The following data type defines binary trees holding integers, which can

write haskell code for the following image text in transcribed
Exercise 3. Binary trees 16+5 = 21 points The following data type defines binary trees holding integers, which can be a leaf with a value or an internal node with a value and two children. data Tree - Node Tree Tree | Leaf Int deriving (Eq,Show) Given this data type, the following function computes the left most integer stored in the tree CSCE 550, Spring 2020. Homework ! leftmost :: Tree -> Int leftmost (Leaf 1) - i leftmost (Node 1 ) - leftmost Complete the following questions. (a) For each function below, give its type and implementat rightmost - undefined -- Compute the right most integer in the tree maxInt - undefined Get the maximum integer from the input binary tree sum Ints - undefined Calculate sum of ali integers stored in a tree balanced - undefined - A tree is balanced 1. for each node, the number eaves in the left and right subtree differ by at most one, with leaves themselves being trivially balanced of 3 (1) Define netton balance that ivert y listo Valinta balanced tre (Note: You may want the elite exiliary function have that plit i list into two halves whoe length differ hy at 1.) Exercise 3. Binary trees 16+5 = 21 points The following data type defines binary trees holding integers, which can be a leaf with a value or an internal node with a value and two children. data Tree - Node Tree Tree | Leaf Int deriving (Eq,Show) Given this data type, the following function computes the left most integer stored in the tree CSCE 550, Spring 2020. Homework ! leftmost :: Tree -> Int leftmost (Leaf 1) - i leftmost (Node 1 ) - leftmost Complete the following questions. (a) For each function below, give its type and implementat rightmost - undefined -- Compute the right most integer in the tree maxInt - undefined Get the maximum integer from the input binary tree sum Ints - undefined Calculate sum of ali integers stored in a tree balanced - undefined - A tree is balanced 1. for each node, the number eaves in the left and right subtree differ by at most one, with leaves themselves being trivially balanced of 3 (1) Define netton balance that ivert y listo Valinta balanced tre (Note: You may want the elite exiliary function have that plit i list into two halves whoe length differ hy at 1.)

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions