Heap & Priority Queue Flashcards

1
Q

What is the time complexity of inserting into a heap?

A

O(log n).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the time complexity of extracting the min/max from a heap?

A

O(log n).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you find the k-largest elements in an array?

A

Use Min-Heap of size K.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does a min-heap differ from a max-heap?

A

Min-Heap stores smallest element at root, Max-Heap stores largest.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Fibonacci heap?

A

Faster amortized insert/decrease-key operations than binary heap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly