Question: Python Project: Implement a class named BinaryTreeStringList. In this class implement a method called add, that when given a string, it adds it to an
Python Project:
Implement a class named BinaryTreeStringList. In this class implement a method called add, that when given a string, it adds it to an internal Binary Tree object. Feel free to use the BinaryTree implementation from the book. Provide a find method on theBinaryTreeStringList class that searches the BinaryTree for the item. Write a test class and a timeit measurement. Write a discussion that compares the find method results in this implementation with the previous implementations from part 2 of this assignment. . In your discussion, include analysis of the time complexity, i.e Big O.
I am struggling with the find portion of this problem. Perhaps I am using the wrong tree type. Here's what I have so far:
----
class BinaryTreeStringList():
def __init__(self,root): self.key = root self.leftChild = None self.rightChild = None
def insertLeft(self, newNode): if self.leftChild == None: self.leftChild = BinaryTreeStringList(newNode) else: t = BinaryTreeStringList(newNode) t.left = self.leftChild self.leftChild = t
def insertRight(self, newNode): if self.rightChild == None: self.rightChild = BinaryTreeStringList(newNode) else: t = BinaryTreeStringList(newNode) t.right = self.rightChild self.rightChild = t
def getLeftChild(self): return self.leftChild
def getRightChild(self): return self.rightChild
def setRootVal(self, obj): self.key = obj
def getRootVal(self): return self.key
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
