1.while 循环结束条件
错误代码
最大索引堆部分的shiftDown操作
def shiftDown(self,i):
currentvalue=self.items[self.indexList[i]]
currentindex=self.indexList[i]
while i*2<=self.currentSize:
mc=self.maxChild(i)
if currentvalue < self.items[self.indexList[mc]]:
self.indexList[i]=self.indexList[mc]
i=mc
else:
break
self.indexList[i]=currentindex
错误的根本原因:没有时刻注意循环停止条件和该状态下各变量的的取值