Heap pattern Flashcards

1
Q

What is a min heap? What is a max heap?

A

It’s a binary tree with two important features
1. complete tree

  1. Every node is less than both children

root is the min value

A max heap is the same as the above except the opposite ordering where the root is the max node

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

What are the typical functions for a heap?

A

top - similar to peak where the current root is returned

push - inserts a new value and after that we still have the two properties preserved.

pop - Removes the min value and after that we still have two properties preserved.

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