Code: Binary Tree: Class DFS: Def - Init - (Self, Data None, Left None, Right None)
Code: Binary Tree: Class DFS: Def - Init - (Self, Data None, Left None, Right None)
Binary Tree
class dfs:
self.data = data
self.left = left
self.right = right
def inorder(root):
inorder(root.left)
inorder(root.right)
if __name__ == '__main__':
root = dfs(1)
root.left = dfs(2)
root.right = dfs(3)
root.left.left = dfs(4)
root.right.left = dfs(5)
root.right.right = dfs(6)
root.right.left.left = dfs(7)
root.right.left.right = dfs(8)
inorder(root)