Construct a tree from the s-expression and implement some functions.
•Construct_tree
•Tree traversal
•Tree height
•Weight sum
•Maximum Path Sum
•Invert
Input will be a string, which is an s-expression of a binary tree.
e.g. (1(2(4()())(5()()))(3(6()())(7()())))
-100 <= Node weight <= 100
0 < Node_id < 100000
For rotate, 0 < k < 100000
After constructing the tree, you have to print the following information of this tree.
In-order traversal
Pre-order traversal
Post-order traversal
Level-order traversal
Height of tree
Weight sum of tree
Maximum path sum of tree
In-order traversal after inverting
Pre-order traversal after inverting
Post-order traversal after inverting
Level-order traversal after inverting
NTHU, DS, Data Structure, Homework, Tree.