Could anyone please help me with my assignment questions? I've done most of it but I'm still stuck on these 3 questions.
Here is the question:
Consider the following types of search trees and balanced trees
data STree = Leaf | Node STree Int STree data Btree = Tip Int | Branch Btree Btreewhose constructors are subject to the following constraints:
- Values of the form
Node left n rightmust have all integers in left being at mostnand all integers in right being greater thann.- Values of the form
Branch left rightmust have a difference between the numbers of integers inleftandrightof at most one.a) Define a recursive function
stree :: [Int] -> STreethat constructs a search tree from a list of integers.b) Define a recursive function
btree :: [Int] -> BTreethat constructs a balanced tree from a non-empty list of integers.c) Using merge, define a recursive function
collapse :: BTree -> [Int]that collapses a balanced tree to give a sorted list of integers.
Please help me!!!
Thanks very much in advance!