-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinorder.py
More file actions
34 lines (30 loc) · 730 Bytes
/
inorder.py
File metadata and controls
34 lines (30 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Node :
def __init__(self, i) :
self.right = None
self.left = None
self.val = i
def push(root, i) :
node = Node(i)
if(root is None) :
root = node
elif(i > root.val) :
if(root.right is None) :
root.right = node
else :
root = root.right
else :
if(root.left is None) :
root.left = node
else :
root = root.left
#----> inorder function
def inorder(node) :
if(node is None) :
return
inorder(node.right)
print(node.val)
inorder(node.right)
root = Node(int(input('Enter Root Node: ')))
top = root
push(top, int(input('Enter Something To Push: ')))
inorder(root)