Heap & Priority Queue Flashcards
1
Q
What is the time complexity of inserting into a heap?
A
O(log n).
2
Q
What is the time complexity of extracting the min/max from a heap?
A
O(log n).
3
Q
How can you find the k-largest elements in an array?
A
Use Min-Heap of size K.
4
Q
How does a min-heap differ from a max-heap?
A
Min-Heap stores smallest element at root, Max-Heap stores largest.
5
Q
What is a Fibonacci heap?
A
Faster amortized insert/decrease-key operations than binary heap.