Last active
August 24, 2017 22:24
-
-
Save micylt/321fd1947f3961d9d397 to your computer and use it in GitHub Desktop.
Counts the number of empty branches within an int tree
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
public int countEmpty() { | |
return countEmpty(this.overallRoot); | |
} | |
private int countEmpty(IntTreeNode overallRoot) { | |
if (overallRoot == null) { | |
return 1; | |
} else { | |
return countEmpty(overallRoot.left) + countEmpty(overallRoot.right); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment