鱼C论坛's Archiver
论坛
›
Python交流
› Python 排序算法:堆排序
zltzlt
发表于 2020-3-22 13:38:50
Python 排序算法:堆排序
Python 排序算法:堆排序
原理
代码
from heapq import heapify, heappop
def heapsort(nums: list) -> list:
heapify(cpy := nums[:]) # heapify() 用于将列表转化为堆结构
return ] # heappop() 用于取出堆中的元素
qiuyouzhi
发表于 2020-3-22 13:47:11
我现在越来越懒了。。。
那个希尔排序你也发了吧
页:
[1]
查看完整版本:
Python 排序算法:堆排序