这个堆里有几个元素
运行下面这段程序:
def push(h, x):
h.append(x)
i = len(h) - 1
while i > 0 and h[(i - 1) // 2] < h[i]:
p = (i - 1) // 2
h[p], h[i] = h[i], h[p]
i = p
h = []
for v in [17, 24, 15, 13, 23]:
push(h, v)
print(len(h))
全部评论