Heap_sort.md
κ°λ
Heap
νΉμ§
ꡬν
import heapq
# μ€λ¦μ°¨μ μ λ ¬
def min_heap(arr):
return heapq.heapify(arr)
# λ΄λ¦Όμ°¨μ μ λ ¬
def max_heap(arr):
result = []
for i in arr:
heapq.heappush(result, (-i, i)) #μ°μ μμ, κ°
return result[1:] #κ³μ°μ μ©μ΄λ₯Ό μν΄ 0λ²μ¨° μΈλ±μ€λ μ¬μ©νμ§ μμ΅λλ€.Last updated