read the value of the root node of a binary tree, adding an element to the level 3 of the tree and extend the implementation with a method

Viewed 16

I have this function of a binary tree:

class Tree:
    def __init__(self,data):
        self.left = None
        self.right = None
        self.data = None

now I should read out the value of the root node with this approach:

root = Tree("")

And then I will add an element to level three of the tree with this approach:

root.left = Tree("leftChild on Level 3")

Can you guys help me further? Thanks in advance

0 Answers
Related