Postorder Traversal of a Binary Tree Using Recursion - Algorithm, Visualization, Examples
⬅ Previous TopicInorder Traversal of a Binary Tree using Iteration
Next Topic ⮕Postorder Traversal of a Binary Tree using Iteration
Next Topic ⮕Postorder Traversal of a Binary Tree using Iteration
Visualization Player
Solution
Algorithm Steps
Code
Python
Java
JavaScript
C
C++
C#
Kotlin
Swift
Go
Php
class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def postorder(root):
if root is not None:
postorder(root.left)
postorder(root.right)
print(root.value, end=' ')
# Example usage:
if __name__ == '__main__':
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
postorder(root)