Skip to content

Commit 1dce053

Browse files
authored
Initial File
Check if two binary trees are identical (Algorithm/code/program)
1 parent de9a8c8 commit 1dce053

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Identical_tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Node:
2+
3+
def __init__(self, data):
4+
self.data=data
5+
self.left=None
6+
self.right=None
7+
8+
9+
def is_identical(root1,root2):
10+
if(root1 == None and root2 == None):
11+
return True
12+
if(root1 != None and root2 != None and root1.data == root2.data):
13+
l = is_identical(root1.left , root2.left)
14+
r = is_identical(root1.right, root2.right)
15+
if(l and r):
16+
return True
17+
return False
18+
return False

0 commit comments

Comments
 (0)