Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. def Count(self):
  2. if not self.Root:
  3. return 0
  4. tree = self.Root
  5. counter = 1
  6. def find(tree, counter):
  7. for node in tree.Children:
  8. counter += 1
  9. if node.Children:
  10. return find(node, counter) # this place
  11. return counter
  12. count = find(tree, counter)
  13. return count
  14.  
  15. def Count(self):
  16. if not self.Root:
  17. return 0
  18. tree = self.Root
  19. counter = [1]
  20. def find(tree, counter):
  21. for node in tree.Children:
  22. counter[0] += 1
  23. print(node.NodeValue)
  24. if node.Children:
  25. find(node, counter)
  26. return counter
  27. count = find(tree, counter)
  28. return count[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement