Null object pattern: Difference between revisions

Content deleted Content added
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Example: format code
Line 34:
 
'''class''' node {
node left
node right
}
 
Line 41:
 
'''function''' tree_size(node) {
return 1 + tree_size(node.left) + tree_size(node.right)
}
 
Line 47:
 
'''function''' tree_size(node) {
set sum = 1
'''if''' node.left exists {
sum = sum + tree_size(node.left)
}
'''if''' node.right exists {
sum = sum + tree_size(node.right)
}
return sum
}
 
Line 60:
 
'''function''' tree_size(node) {
return 1 + tree_size(node.left) + tree_size(node.right)
}
 
'''function''' tree_size(null_node) {
return 0
}