Determine if two binary trees are equal

前端 未结 7 1988
臣服心动
臣服心动 2020-12-04 22:33

What would be the efficient algorithm to find if two given binary trees are equal - in structure and content?

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 23:13

    We can also do any of the two traversals (pre-order, post-order or in-order) and then compare the results of both the trees. If they are same, we can be sure of their equivalence.

提交回复
热议问题