I need help in 3 tasks. I'm really new in Haskell and functional programming.
data Tree = Node Int Tree Tree | Nil
Define with help of the function
collapsecollapse :: Tree -> [Int] collapse Nil = [] collapse (Node x y z) = (collapse y) ++ [x] ++ (collapse z)a Haskell-Function
check :: Tree -> Boolwhich checks if the Tree is a binary search tree.I test that with a tree and get
2 4 7 8 10 | 5 6 10 12. Here you can see that all values to the middle are sorted, but I don't know how i should code that.Define a Haskell-Function
insert :: Int -> Tree -> Treewhich adds the Integer Value to the Tree and return also a binary search tree.Define with the function
insert(2) a Haskell-Functionmerge :: Tree -> Tree -> Treewhich merges two trees to another binary search tree.
collapseis an in-order traversal. What property of in-order traversals of binary trees characterises binary search trees? - Daniel Fischer