Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BinaryTreeVertex:
- '''vertex controls for the BST'''
- def __init__(self, value):
- self.right = None
- self.left = None
- self.value = value
- ...
- def total_Depth(self):
- print ("val:", self.value)
- if self.left and self.right:
- return (self.left.total_Depth()) + 1 and (self.right.total_Depth()) + 1
- elif self.left:
- return 1 + self.left.total_Depth()
- elif self.right:
- return 1 + self.right.total_Depth()
- else:
- return 1
- ...
- tree = BinarySearchTree()
- arr = [6,10,20,8,3]
- for i in arr:
- tree.insert(i)
- tree.searchPath(20)
- print (tree.total_Depth())
Add Comment
Please, Sign In to add comment