Find whether a tree is a subtree of other

后端 未结 10 2026
一个人的身影
一个人的身影 2020-12-28 11:57

There are two binary trees T1 and T2 which store character data, duplicates allowed.
How can I find whether T2 is a subtree of T1 ? .
T1 has millions of nodes and

10条回答
  •  长发绾君心
    2020-12-28 12:48

    If given the root of both trees, and given that the nodes are of the same type, why is then just ascertaining that the root of T2 is in T1 not sufficient?

    I am assuming that "given a tree T" means given a pointer to the root of T and the data type of the node.

    Regards.

提交回复
热议问题