2018bug收集

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

错误的根本原因:没有时刻注意循环停止条件和该状态下各变量的的取值

猜你喜欢

转载自blog.csdn.net/ahaotata/article/details/82631282