Question: Haskell: explain 2021 data Tree = Leaf Node Tree Int Tree flatten :: Tree [Int] flatten Leaf =[ flatten (Node 1nr ) = flatten 1++[n]++
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
Get step-by-step solutions from verified subject matter experts
