# | Likes | Tech tags | Title | Creator | Created date |
---|---|---|---|---|---|
1 | 0 |
2022-07-31 03:21
|
|||
2 | 0 |
2022-10-31 00:50
|
A heap class from the C++ Standard Template Library providing \(O(\log n)\) insertion and \(O(\log n)\) deletion.
#include <queue>
int main() {
std::priority_queue<int> heap;
heap.push(5);
int max_element = heap.top();
heap.pop();
}
Heap Data Structures - tutorialspoint.com
Chapter 6.1: Heaps - Introduction to Algorithms, Third Edition (Thomas H. Cormen, Charles E. Leiserson, Ronald Rivest, Clifford Stein)
classes | ||
std::priority_queue |
en.cppreference.com | cplusplus.com |
functions | ||
std::priority_queue::pop |
en.cppreference.com | cplusplus.com |
std::priority_queue::push |
en.cppreference.com | cplusplus.com |
std::priority_queue::top |
en.cppreference.com | cplusplus.com |
Implement a max-heap data structure. Insert an element into it, then fetch the maximum element, then delete said maximum element.