if self.root is None:
self.psroot.left = self.NodeType(self.psroot, t)
self.reroot()
return self.root
else:
return self.root.insert(t, self.NodeType)
def find(self, t):
if self.root is None:
return None
else:
return self.root.find(t)
def delete(self, t):
deleted = self.root.delete()
return
node = self.find(t)
if node:
#deleted = self.root.delete()
deleted = node.delete()
self.reroot()
return deleted
return None
def __str__(self):
134
if self.root is None: return ''
def recurse(node):
if node is None: return [], 0, 0
label = str(node.key)
left_lines,
left_pos,
left_width
=
recurse(node.left)
right_lines,
right_pos,
right_width
Do'stlaringiz bilan baham: |