Guest User

Untitled

a guest
Feb 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class BinaryTreeVertex:
  2. '''vertex controls for the BST'''
  3. def __init__(self, value):
  4. self.right = None
  5. self.left = None
  6. self.value = value
  7.  
  8.  
  9. ...
  10. def total_Depth(self):
  11. print ("val:", self.value)
  12. if self.left and self.right:
  13. return (self.left.total_Depth()) + 1 and (self.right.total_Depth()) + 1
  14. elif self.left:
  15. return 1 + self.left.total_Depth()
  16. elif self.right:
  17. return 1 + self.right.total_Depth()
  18. else:
  19. return 1
  20. ...
  21. tree = BinarySearchTree()
  22. arr = [6,10,20,8,3]
  23. for i in arr:
  24. tree.insert(i)
  25. tree.searchPath(20)
  26. print (tree.total_Depth())
Add Comment
Please, Sign In to add comment