Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python invert binary tree

from collections import deque
def levelOrderTraversal(root):
    q = deque()
    q.append(root)
    while q:
        curr = q.popleft()
        print(curr.data, end=' ')
        if curr.left:
            q.append(curr.left)
        if curr.right:
            q.append(curr.right)
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #python #invert #binary #tree
ADD COMMENT
Topic
Name
8+4 =