我正在尝试在我的AVL树的这个节点内创建一个列表,我也试过一个函数,有人有一些库要导入或有些想法吗?
#import random, math
import re
outputdebug = False
def debug(msg):
if outputdebug:
print msg
class Node():
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.list = [] #list at the node
class AVLTree():
def __init__(self, *args):
self.node = None
self.height = -1
self.balance = 0;
def ad_list(self, value):
self.list.append(value) #function trying to add
def print_list(self):
print self.list
答案 0 :(得分:0)
您的AVLTree
班级没有列表,只有Node
班级:
self.node.list.append(value) #function trying to add