I would like to create a data type which represents a binary tree which has the values stored only in the leaves, then a function sub to check if a tree is subtree of other tree.
Here is my code, but I got no idea how to implement the function sub.
data BinaryTree a = Leaf a | Node (BinaryTree a) (BinaryTree a) deriving Show
makeBinTree :: [a] -> BinaryTree a
makeBinTree lst = head $ mrg leaves
where
leaves = map (\x -> Leaf x) lst
mrg [] = []
mrg [x] = [x]
mrg (x:y:xs) = mrg ( (Node x y) : mrg xs)
sub :: Eq a => BinaryTree a -> BinaryTree a -> Bool