Skip to content

Construct a tree from the s-expression and implement some functions.

Notifications You must be signed in to change notification settings

whtseng1/NTHU_CS_DS_2018Fall_HW3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NTHU_CS_DS_2018Fall_HW3

Construct a tree from the s-expression and implement some functions.

implementation

•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

0 < Node_id < 100000
For rotate, 0 < k < 100000

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

Keywaords

NTHU, DS, Data Structure, Homework, Tree.

Reference

http://140.114.86.238/problem/12052/

About

Construct a tree from the s-expression and implement some functions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages