CareerCup 4.8

来源:互联网 发布:淘宝客服售后面试问题 编辑:程序博客网 时间:2024/05/22 00:52

4.8 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.

A tree T2 is a subtree of T1 if there exists a node n in T1 such that the subtree of n is identical to T2. That is, if you cut off the tree at node n, the two trees would be identical.