Question: Use the following data type for Problems 5 and 6. a b - Leaf a I Branch b (Tree2 a b) (Tree2 a ) Leaf

 Use the following data type for Problems 5 and 6. a

b - Leaf a I Branch b (Tree2 a b) (Tree2 a

Use the following data type for Problems 5 and 6. a b - Leaf a I Branch b (Tree2 a b) (Tree2 a ) Leaf a | Branch b (Tree2 a b) (Tree2 a b) Problem 5. (10 points) Make Tree2 an instance of Show. Do not use deriving; define the instance yourself. Make the output look somewhat nice (e.g., indent nested branches) Problem 6. (10 points) Implement the two functions that traverse the tree in the given order collecting the values from the tree nodes into a list: preorder :: (a -> c) -> (b -> c) -> Tree2 a b -> [c] inorder :: (a -> c) -> (b -c) -> Tree2 a b - [c] Use the following data type for Problems 5 and 6. a b - Leaf a I Branch b (Tree2 a b) (Tree2 a ) Leaf a | Branch b (Tree2 a b) (Tree2 a b) Problem 5. (10 points) Make Tree2 an instance of Show. Do not use deriving; define the instance yourself. Make the output look somewhat nice (e.g., indent nested branches) Problem 6. (10 points) Implement the two functions that traverse the tree in the given order collecting the values from the tree nodes into a list: preorder :: (a -> c) -> (b -> c) -> Tree2 a b -> [c] inorder :: (a -> c) -> (b -c) -> Tree2 a b - [c]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!