MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / percUp

Method percUp

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

Source from the content-addressed store, hash-verified

6
7 #插入新结点后必要时交换子节点和父节点的位置保持堆的性质
8 def percUp(self, i):
9 while i//2 > 0:
10 if self.heapList[i] < self.heapList[i//2]:
11 temp = self.heapList[i//2]
12 self.heapList[i//2] = self.heapList[i]
13 self.heapList[i] = temp
14 i = i//2
15
16 # 插入节点
17 def insert(self, k):

Callers 1

insertMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected