Chapter 12: Heaps Flashcards

1
Q

How is a heap different from a binary search tree?

A

BST’s guarantees global order, where heaps only guarantee level orders

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

When do you use a heap over a BST?

A

If you only care about min and max operations, BST’s are good at all finds (O(logn))

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

How does heapsort work? (High-level)

A

Take unsorted array and insert into a heap. Removing from the heap will return items in a sorted order!

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

What is the runtime of heapsort?

A

O(n log n)

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

What is the run time of heap insert and remove?

A

O(log n)

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