Answers for "invert binary tree module"

1

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)
Posted by: Guest on July-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language