May 2017
Intermediate to advanced
310 pages
8h 5m
English
Postfix or reverse Polish notation (RPN) places the operator after its operands, as in 3 4 +. As is the case with Polish notation, there is never any confusion over the precedence of operators, so parentheses are never needed: 4 5 + 5 3 - *.
In this mode of traversal, you would visit the left sub-tree, the right sub-tree, and lastly the root node.
The post-order method is as follows:
def postorder(self, root_node): current = root_node if current is None: return self.postorder(current.left_child) self.postorder(current.right_child) print(current.data)