se, help. I'm working with notebook python. class Tree: """A rooted binary tree""" def __init__(self): self.root = None self.left = None self.right = None def is_empty(tree: Tree) -> bool: """Return True if and only if tree is empty.""" return tree.root == tree.left == tree.right == None def join(item: object, left:
Please, help. I'm working with notebook python.
class Tree:
"""A rooted binary tree"""
def __init__(self):
self.root = None
self.left = None
self.right = None
def is_empty(tree: Tree) -> bool:
"""Return True if and only if tree is empty."""
return tree.root == tree.left == tree.right == None
def join(item: object, left: Tree, right: Tree) -> Tree:
"""Return a tree with the given root and subtrees."""
tree = Tree()
tree.root = item
tree.left = left
tree.right = right
return tree
The following code builds a binary tree, MORSE, which implements the upper-case Morse code, as per the image below. More information on Morse code can be found on Wikipedia. You will need to run this code block to use in your solutions.
Step by step
Solved in 2 steps