Null object pattern: Difference between revisions

Content deleted Content added
Tag: Reverted
Tag: Reverted
Line 46:
}
 
One may implement a tree size procedure recursively:
 
'''function''' tree_size(node){
return 1 + tree_size(node.left) + tree_size(node.right)
}
 
Since the child nodes may not exist, one must modify the procedure by adding non-existence or null checks: