MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / node

Class node

sorts/tree_sort.py:4–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2# Build a BST and in order traverse.
3
4class node():
5 # BST data structure
6 def __init__(self, val):
7 self.val = val
8 self.left = None
9 self.right = None
10
11 def insert(self,val):
12 if self.val:
13 if val < self.val:
14 if self.left is None:
15 self.left = node(val)
16 else:
17 self.left.insert(val)
18 elif val > self.val:
19 if self.right is None:
20 self.right = node(val)
21 else:
22 self.right.insert(val)
23 else:
24 self.val = val
25
26def inorder(root, res):
27 # Recursive travesal

Callers 2

insertMethod · 0.85
treesortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected