Rekursive Datentypen

data Tree = Leaf {}
    | Branch { left :: Tree, key :: Int
             , right :: Tree }
full :: Int -> Tree -- vollst. binärer Baum
full h = if h > 0 
    then Branch { left = full (h-1)
          , key = h, right = full (h-1) }
    else Leaf { }
leaves :: Tree -> Int
leaves t = case t of
    Leaf   {} -> 1
    Branch {} -> ...

Aufgabe: maximal unbalancierte AVL-Bäume



Johannes Waldmann 2011-01-18