The reconstruct_binary_tree.cpp file contains 2 challenges involving binary trees.
Its main function creates a binary tree and prints out its contents one-dimensionally in 4 different orders: pre-order, in-order, post-order and level-order.
The 4 different orders are implemented in the file (treelist function) and can be examined there.
The challenges are:
- Reconstruct an identical tree using the pre-order and in-order list.
- Reconstruct an identical tree using the in-order and level-order list.
The main function prints out all lists of the tree, as well as those of the trees returned by your solutions, and indicates if the solution was successful.
Output looks like this:
pre: A, B, D, E, C, F, G
in: D, B, E, A, F, C, G
post: D, E, B, F, G, C, A
level: A, B, C, D, E, F, G
== challenge1 output:
pre:
in:
post:
level:
success: false
== challenge2 output:
pre:
in:
post:
level:
success: false
More test cases may be added.