Languages/Python
[heapq] 최소힙, 최대힙
import heapq 최소값 혹은 최대값을 자주 참조하면서 자료구조 원소들을 변경하는 경우 힙을 사용하는게 유리합니다. 파이썬에서 제공하는 heap 자료구조 입니다. 배열을 heap 구조로 사용할 수 있고, push pop 기능을 제공합니다. heapq — Heap queue algorithm Source code: Lib/heapq.py This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm. Heaps are binary trees for which every parent node has a va... docs.python.org 기본적으로 최소힙 형태로 ..