From 8379919686d791e3e003bfb0fad80a990f2710b6 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Wed, 15 Apr 2015 11:27:58 +0800 Subject: +63 --- H63.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/H63.hs b/H63.hs index 03f081e..0996960 100644 --- a/H63.hs +++ b/H63.hs @@ -1,8 +1,12 @@ import Tree +import Control.Applicative completeBinaryTree n = makeTree 1 where makeTree x | x > n = Empty | otherwise = Branch 'x' (makeTree (2*x)) (makeTree (2*x+1)) -isCompleteBinaryTree +isCompleteBinaryTree t = b>a where + [a, b] = getZipList $ maxmin t 1 + maxmin Empty m = ZipList [0, m] + maxmin (Branch _ l r) m = ZipList [max.(max m),min] <*> (maxmin l (2*m)) <*> (maxmin r (2*m + 1)) -- cgit v1.2.3-70-g09d2