Question: Haskell: explain 2021 data Tree = Leaf Node Tree Int Tree flatten :: Tree [Int] flatten Leaf =[ flatten (Node 1nr ) = flatten 1++[n]++

Haskell: explain 2021 Haskell: explain 2021 data Tree = Leaf Node Tree Int Tree flatten

data Tree = Leaf Node Tree Int Tree flatten :: Tree [Int] flatten Leaf =[ flatten (Node 1nr ) = flatten 1++[n]++ flatten r A tree is called search tree if it flattens to a list that is ordered. (i) Give two examples of trees such that one of them is a search tree but the other isn't. Compute the flattenings of both trees. (ii) Write a function insert such thift if n is an integer and t is a search tree then insert nt is again a search tree that contains the nodes of t and in addition the integer n. If n occurs already in t, then insert nt should be equal to t

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!