12052 - DS_2018Fall_Homework3
|
Time |
Memory |
| Case 1 |
1 sec |
32 MB |
| Case 2 |
1 sec |
32 MB |
| Case 3 |
1 sec |
32 MB |
| Case 4 |
1 sec |
32 MB |
| Case 5 |
1 sec |
32 MB |
| Case 6 |
5 sec |
64 MB |
Description
In this homework, we need to construct a tree from the s-expression and implement the following functions.
Construct_tree
Tree traversal
Tree height
Weight sum
Maximum Path Sum
Invert
Input
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
Output
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
Partial Judge Code
12052.cpp
Partial Judge Header
12052.h
Tags