summaryrefslogtreecommitdiff
path: root/H62.hs
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-04-13 15:21:21 +0800
committerJoe Zhao <ztuowen@gmail.com>2015-04-13 15:21:21 +0800
commita39aea354b071612c071d98125e879fe14c76a54 (patch)
tree9d960eb2c970245e4fa5ffc2b51c25e0547972fb /H62.hs
parent84e6753005e57827c78b50ad0a26ffa0d0da55e4 (diff)
downloadh99-a39aea354b071612c071d98125e879fe14c76a54.tar.gz
h99-a39aea354b071612c071d98125e879fe14c76a54.tar.bz2
h99-a39aea354b071612c071d98125e879fe14c76a54.zip
+61 +62 +63
Diffstat (limited to 'H62.hs')
-rw-r--r--H62.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/H62.hs b/H62.hs
new file mode 100644
index 0000000..b835b20
--- /dev/null
+++ b/H62.hs
@@ -0,0 +1,14 @@
+import Tree
+-- import Tree4
+
+leaves Empty = []
+leaves (Branch x Empty Empty) = [x]
+leaves (Branch x t1 t2) = leaves t1 ++ leaves t2
+
+internals Empty = []
+internals (Branch x Empty Empty) = []
+internals (Branch x t1 t2) = [x] : internals t1 ++ internals t2
+
+atLevel Empty _ = []
+atLevel (Branch x _ _) 1 = [x]
+atLevel (Branch _ t1 t2) n = atLevel t1 (n-1) ++ atLevel t2 (n-1)