Skip to content

Commit a5b4858

Browse files
authored
Initial File
Convert binary tree to mirror image
1 parent c169a10 commit a5b4858

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

binary_mirror

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Node:
2+
def __init__(self,data):
3+
self.data=data
4+
self.left=None
5+
self.right=None
6+
7+
def get_mirror(root):
8+
if(root == None):
9+
return
10+
get_mirror(root.left)
11+
get_mirror(root.right)
12+
13+
temp=root.left
14+
root.left=root.right
15+
root.right=temp
16+
17+
def preorder(root):
18+
if(root==None):
19+
return
20+
print(root.data, end=" ")
21+
preorder(root.left)
22+
preorder(root.right)

0 commit comments

Comments
 (0)