# 删除堆顶元素后, 交换堆尾和空堆顶的位置并实现元素的下沉 def percDown(self, i): while (i*2) <= self.currentSize: mc = self.minChild(i) if self.heapList[i] > self.heapList[mc]: temp = self.heapList[i] self.heapList[i] = self.heapList[mc] self.heapList[mc] = temp else: break
Activity
xStone9527 commentedon Sep 7, 2018
还有 交换元素 每次弄个temp出来,怪麻烦的,既然已经 python了,为什么不a,b=b,a 呢?
LinjingBi commentedon Dec 20, 2018
我觉得这个python版的剑指offer可能是根据c++版改写过来的,所以有很多地方python都可以更简便,但是因为只是单纯的改写就没有了python的特点。