Min-Max Heap
(data-structure/min_max_heap.hpp)
Description
Min-max heap は,要素の最大値と最小値を取得することのできるヒープである.
Operations
-
MinMaxHeap(vector<T> v)
- $v$ の要素から min-max heap を構築する
- 時間計算量: $O(n)$
-
void insert(T x)
- $x$ を挿入する
- 時間計算量: $O(\log n)$
-
T min_element()
-
T max_element()
-
void erase_min()
- 最小値を削除する
- 時間計算量: $O(\log n)$
-
void erase_max()
- 最大値を削除する
- 時間計算量: $O(\log n)$
Reference
Verified with
Code
Back to top page