def __str__(self): if self.root is None: return 'BinaryTree()' buff = 'BinaryTree(' for x in node.traverse(self.root): buff += '%s, ' % x buff = buff.rstrip(', ') buff += ')' return buff
def __str__(self): if self.root is None: return 'BinaryTree()' buff = 'BinaryTree(' for x in node.traverse(self.root): buff += '%s ' % x buff = buff.rstrip(', ') buff += ')' return buff
def traverse(self): for x in node.traverse(self.root): yield x