diff options
author | Determinant <ted.sybil@gmail.com> | 2017-05-29 22:25:03 -0400 |
---|---|---|
committer | Determinant <ted.sybil@gmail.com> | 2017-05-29 22:25:03 -0400 |
commit | 8ea7effa639a0640b38917a9f575aedebcdd2b78 (patch) | |
tree | 7916f64813dc89459ae62add344778fedafb3872 /54a-60/59.hs | |
parent | d0aa856bedb0c0223b4ce2a67f5582b8eadf3682 (diff) |
finish v6
Diffstat (limited to '54a-60/59.hs')
-rw-r--r-- | 54a-60/59.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/54a-60/59.hs b/54a-60/59.hs new file mode 100644 index 0000000..0faecd6 --- /dev/null +++ b/54a-60/59.hs @@ -0,0 +1,11 @@ +data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq) + +hbalTree :: a -> Int -> [Tree a] + +hbalTree x 0 = [Empty] +hbalTree x 1 = [Branch x Empty Empty] +hbalTree x h = + [Branch x lt rt + | (h1, h2) <- [(h-2, h-1), (h-1, h-2), (h-1, h-1)] + , lt <- hbalTree x h1 + , rt <- hbalTree x h2] |