Heap Flashcards

1
Q

What is a Heap

A

A complete tree with the heap order property

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

what is the heap order property

A

the key stored at v is >= the key stored at vs parent

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

which node is the last node

A

the rightmost deepest node

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

what is the height of a heap

A

log(n+1)

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

why is vector representation a good way to store a heap

A

because it is complete

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

describe min heap

A

smallest item is at the top and increase going down

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

what does it mean to bubble up

A

when we insert, we then have to bubble up. this is done by swapping parent and child to preserve heap order

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

how do we remove min

A

the min is always the root.

replace the root with the last element to preserve completeness and bubble down to preserve heap order

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

can we store a heap using a linked structure? why?

A

no because we want to know where the last element is

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