// Ch4.7: You have two very large binary trees: T1, with millions of nodes, and T2,
// with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1
#include
#include
#include
#include
implement the preetydraw snippets from leetcode for demonstration.
Executing the program....
$demo
Balanced tree in array format
a1:
0----------6
3 1 0 2 5 4 6 Tree pretty print with level=1 and indentSpace=0
___3__
/ \
_1 _5
/ \ / \
0 2 4 6
a2:
0----------2
1 0 2 Tree pretty print with level=1 and indentSpace=0
_1
/ \
0 2
So we can easily verify that a2 is a subtree of a1.