MCPcopy Index your code
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / percDown

Method percDown

BinaryHeap.py:23–30  ·  view source on GitHub ↗
(self, i)

Source from the content-addressed store, hash-verified

21
22 # 删除堆顶元素后, 交换堆尾和空堆顶的位置并实现元素的下沉
23 def percDown(self, i):
24 while (i*2) <= self.currentSize:
25 mc = self.minChild(i)
26 if self.heapList[i] > self.heapList[mc]:
27 temp = self.heapList[i]
28 self.heapList[i] = self.heapList[mc]
29 self.heapList[mc] = temp
30 i = mc
31
32 def minChild(self, i):
33 if i * 2 + 1 > self.currentSize:

Callers 2

delMinMethod · 0.95
buildHeapMethod · 0.95

Calls 1

minChildMethod · 0.95

Tested by

no test coverage detected