summaryrefslogtreecommitdiff
path: root/54a-60/59.hs
diff options
context:
space:
mode:
Diffstat (limited to '54a-60/59.hs')
-rw-r--r--54a-60/59.hs11
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]