Visualization of a Binary Tree Creation
Let’s understand binary tree creation details by a little example.
The Definition of
TreeNode is the following.
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
root— the variable is useful to access the binary tree
curnode— the variable is for iteration inside of the binary tree