#K9701. Symmetric Binary Tree
Symmetric Binary Tree
Symmetric Binary Tree
Given a binary tree represented in level order as a list of integers (with -1 indicating a null node), determine if the tree is symmetric around its center. A tree is symmetric if it is a mirror of itself, i.e., for every node, the left subtree is a mirror reflection of the right subtree. In mathematical notation, a binary tree T is symmetric if:
Note: The tree is constructed using the indexing scheme where for a node at index (i), its left child is at (2i+1) and right child at (2i+2).
inputFormat
Input is provided via a single line from standard input containing space-separated integers. These integers represent the level order traversal of the binary tree, where -1 marks a null node. An empty input indicates an empty tree.
outputFormat
Output a single line to standard output containing either 'True' or 'False'. 'True' should be printed if the binary tree is symmetric; otherwise, 'False'.## sample
1 2 2 3 4 4 3
True