Symmetric Binary Tree

We say that a binary tree is symmetric if it is made up of exactly similar items facing each other around the root of the binary tree. In other words, suppose we draw vertical line that start from the root node, the tree is symmetric if all nodes with the same distance from this line in the same level are equal.

Let's some examples of a symmetric binary tree

The tree Symmetric Why?
binary tree graph Yes 2=2
3=3
4=4
binary tree graph Yes 2=2
4=4
X=X
binary tree graph Yes 2=2
X=X
3=3
binary tree graph No 5 != 4
binary tree graph No 2 != 5

The quiz

You get level-based representation of a binary tree.

Part 1

Suppose we have the following class

Node in binary tree
 class Node:
     def __init__(self,data:int,left:'Node',right:'Node'):
         self.data  = data
         self.left  = left
         self.right = right

Write a function, that check the binary tree is symmetric

is_symmetric
 def is_symmetric( root : Node) -> bool:
     pass

Part 2

Write a function, that check the binary tree is symmetric with constant memory

is_symmetricA
 def is_symmetricA( data : List[int,None] ) -> bool:
     pass