Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class tree: def __init__(self, key): self.key = key self.left = None self.right = None def find_longest_word(self): res = root.data t2 = tree('apple') t2.left = tree('banana')
class tree: def __init__(self, key): self.key = key self.left = None self.right = None def find_longest_word(self): res = root.data t2 = tree('apple') t2.left = tree('banana') t2.left.right = tree('orange') t2.right = tree('strawberry') t2.right.left = tree('grape') t2.right.left.right = tree('peach') print(find_longest_word)
Hello, need help with this python code. Im trying to have a binary tree that can determine which nodes have the longest words. I got stuck on the function part. please help and thank you. It should return strawberry!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started