Question
Can someone help me create these functions? Text: class HashTable: def __init__(self): #set a fixed capacity self.capacity = 16 #create the bucketlist self.bucket_list = []
Can someone help me create these functions?
Text:
class HashTable: def __init__(self): #set a fixed capacity self.capacity = 16 #create the bucketlist self.bucket_list = [] #fill the bucketlist with empty arrays for i in range(self.capacity): self.bucket_list.append([]) def insert(self, key): pass def contains(self, key): return False def remove(self, key): pass class PrefixParsingTreeNode: def __init__(self, token, left, right): self.token = token self.left = left self.right = right class PrefixParsingTree: def __init__(self): self.root = None class Tokenizer: def __init__(self, str_statement): self.statement = str_statement self.position = 0 def get_next_token(self): i = self.position while i _name_ == "_main_": # MAKE ALL TEST CODE BELOW THIS LINE # AND AT THIS INDENT LEVEL!! print("testing hash table") test_hash_table() print("testing prefix tree") test_prefix_tree("- 12 + 4 5") test_prefix_tree("+ 12 + - 21 5 5") test_prefix_tree("+ 4 + - 4 6 - 9 8") test_prefix_tree("- + - + 6 9 8 + 1 + 5 5 - - + 6 7 - 9 8 - + 9 6 1") test_prefix_tree("+ + 8 4 - + - 3 3 2 - + 7 8 9") bullet_list_tree = parse_bracket_file("bracket_file_01.txt") write_bulleted_file("bullet_file_01.txt", bullet_list_tree) write_labelled_file("label_file_01.txt", bullet_list_tree)
class HashTable: def __init__(self): #set a fixed capacity self.capacity = 16 #create the bucketlist self.bucket_list = [] #fill the bucketlist with empty arrays for i in range(self.capacity): self.bucket_list.append( []) def insert (self, key) : pass def contains(self, key): return false def remove(self, key): pass class PrefixParsingTreeNode: def __init__(self, token, left, right): self.token = token self. left = left self.right = right class PrefixParsingTree: def __init__(self): self.root = None class Tokenizer: def __init__(self, str_statement): self.statement = str_statement self.position = 0 def get_next_token(self): i = self.position while i {child{grandchild}}} Can go deeper, to any level O I O write_bulleted_file(filename, my_tree) Takes in the name of the output file as a parameter Takes as the second parameter whatever data structure you choose as the entry point to your tree. Could be a tree class Could be a node (root) Same as parse_bracket_file() returns. Writes the text value of each node in a separate line. Starts each line with a number of TAB equal to the depth of the node in the tree (root is depth 0 and has no value). TAB is "t" in a string. o 0 write_labelled_file(filename, my_tree) Same as write_bulleted_file(my_tree). In addition Each first level bulletin is numbered before the "t" Each second level bulletin is lettered before the second "\" a) b) C) All other bulletins have a dash before the last "\t" H1 class HashTable: def __init__(self): #set a fixed capacity self.capacity = 16 #create the bucketlist self.bucket_list = [] #fill the bucketlist with empty arrays for i in range(self.capacity): self.bucket_list.append( []) def insert (self, key) : pass def contains(self, key): return false def remove(self, key): pass class PrefixParsingTreeNode: def __init__(self, token, left, right): self.token = token self. left = left self.right = right class PrefixParsingTree: def __init__(self): self.root = None class Tokenizer: def __init__(self, str_statement): self.statement = str_statement self.position = 0 def get_next_token(self): i = self.position while i {child{grandchild}}} Can go deeper, to any level O I O write_bulleted_file(filename, my_tree) Takes in the name of the output file as a parameter Takes as the second parameter whatever data structure you choose as the entry point to your tree. Could be a tree class Could be a node (root) Same as parse_bracket_file() returns. Writes the text value of each node in a separate line. Starts each line with a number of TAB equal to the depth of the node in the tree (root is depth 0 and has no value). TAB is "t" in a string. o 0 write_labelled_file(filename, my_tree) Same as write_bulleted_file(my_tree). In addition Each first level bulletin is numbered before the "t" Each second level bulletin is lettered before the second "\" a) b) C) All other bulletins have a dash before the last "\t" H1Step 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