#K41077. Mirror Binary Tree Inorder Traversal

    ID: 26785 Type: Default 1000ms 256MiB

Mirror Binary Tree Inorder Traversal

Mirror Binary Tree Inorder Traversal

Given a binary tree T represented in level order, convert it into its mirror. The mirroring operation swaps the left and right children for every node. Mathematically, if a node v has left child L and right child R, then in the mirrored tree, L and R are swapped, i.e. \(L' = R\) and \(R' = L\).

After mirroring the tree, output the inorder traversal of the mirrored tree, with node values separated by a single space. If the input tree is empty, output an empty line.

inputFormat

The input is provided as a single line containing the level order representation of a binary tree. The node values are integers separated by spaces. The string "null" denotes the absence of a node.

outputFormat

Output a single line containing the inorder traversal of the mirrored tree. Node values should be printed in order and separated by a single space.## sample

1 2 3 4 5 6 7
7 3 6 1 5 2 4