Created
October 20, 2013 03:38
-
-
Save kghost/7064763 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class BinaryTree(left: BinaryTree, right: BinaryTree) | |
def isFull(tree: BinaryTree): Boolean = { | |
def FullWithHeight(tree: BinaryTree): Int = { | |
if (tree == null) 0 else { | |
val l = FullWithHeight(tree.left) | |
val r = FullWithHeight(tree.right) | |
if (l >= 0 && l == r) l+1 else -1 | |
} | |
} | |
FullWithHeight(tree) >= 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment