Pergunta de entrevista da empresa EFI

How to find whether two trees are equal?

Respostas da entrevista

Sigiloso

30 de jan. de 2018

Wrote an algorithm and explained

Sigiloso

7 de jul. de 2021

We can solve the answer through recursion. At each step we check if the parent element are equals or not & their left and right child are equals or not. def sameTree(t1, t2): if t1 is None and t2 is None: return True return sameTree(t1.root, t2.root) and sameTree(t1.left, t2.left) and sameTree(t1.right, t2.right)