Python 中的 heapq 库


Author: yifei / Created: June 22, 2018, 5:01 p.m. / Modified: June 22, 2018, 5:03 p.m. / Edit

there is no data structure called heap in python, rather, python stores some functions in the heapq lib

heap is just an array that can be treated as a tree.

heap.nlargest
heap.nsmallest
heap.heapify(l)
heapq.heappop()
heapq.heappush()

有任何问题可以发邮件到 kongyifei (at) gmail.com 讨论