Heap Tree Flashcards
1
Q
What are the types of heaps?
A
max-heaps and min-heaps
1
Q
What are heaps mainly used for?
A
Heap sorts and priority queues
2
Q
What is a max-heap?
A
Max heaps are where the value of i is less than or equal to the value of their parent.
The parent is always bigger
3
Q
What is a min-heap?
A
Minheaps are where the value of i is greater than or equal to the value of their parent.
The parent is always smaller
4
Q
Height of a heap?
A
O(logn)
5
Q
Visualized as an array, where is the root?
A
At index 1
6
Q
Visualized as an array, where is the left child?
A
left(i) = 2*i
7
Q
Visualized as an array, where is the right child?
A
right(i) = 2 * i +1
8
Q
Visualized as an array, how to get to the parent?
A
parent(i) = floor(i/2)