Created
May 16, 2019 21:51
-
-
Save Mintri1199/14148f707140e7ec42fd8a298aaf5832 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
class DecimalTreeNode { | |
... | |
func isLeaf() -> Bool { | |
// Check if the current node is a leaf or not | |
// Count the number of nil values in self.next | |
for item in self.next { | |
if item != nil { // There is a child of the node | |
return false | |
} | |
} | |
// The node has no children | |
return true | |
} | |
func isBranch() -> Bool{ | |
// Check if the current node is a branch or not | |
return !self.isLeaf() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment