-->
当前位置:首页 > 题库

PROGRAMMING:Exchange left child and right child of each node in binary tree

Luz5年前 (2021-05-10)题库395
The binary list is used as the storage structure of the binary tree to exchange the left child and the right child of each node in the binary tree.
###Input format:
Enter the precedence sequence of the binary tree.
Tip: the precedence sequence of a binary tree is a string. If the character is' # ', it means that the binary tree is empty. Otherwise, the character is the data element of the corresponding node.
###Output format:
The output has two lines:
The first line is the middle order traversal sequence of the original binary tree;
The second line is the middle order traversal sequence of the exchanged binary tree.
###Input example:
ABC##DE#G##F###
###Output example:
CBEGDFA
AFDGEBC






answer:If there is no answer, please comment