File Name: simple-tree.py ```python
from testUtils import solution_title, print_and_assert_new, getTestResult
from commonUtils import timeComplexity, spaceComplexity
print('\n >>> Simple Tree Implementation')
class TreeNode: def init(self, value): self.value = value self.children = []
1 2 3 4 5 6 7 8 9 |
|
ceo = TreeNode('CEO') finance = TreeNode('Finance Head') marketing = TreeNode('Marketing Head') it = TreeNode('IT Head')
ceo.add_child(finance) ceo.add_child(marketing) ceo.add_child(it)
finance_lead = TreeNode('Finance Lead') marketing_lead = TreeNode('Marketing Lead') it_lead = TreeNode('IT Lead')
finance.add_child(finance_lead) marketing.add_child(marketing_lead) it.add_child(it_lead)
ceo.traverse_child()```