Heap Flashcards
What is a Heap
A complete tree with the heap order property
what is the heap order property
the key stored at v is >= the key stored at vs parent
which node is the last node
the rightmost deepest node
what is the height of a heap
log(n+1)
why is vector representation a good way to store a heap
because it is complete
describe min heap
smallest item is at the top and increase going down
what does it mean to bubble up
when we insert, we then have to bubble up. this is done by swapping parent and child to preserve heap order
how do we remove min
the min is always the root.
replace the root with the last element to preserve completeness and bubble down to preserve heap order
can we store a heap using a linked structure? why?
no because we want to know where the last element is