Heaps Flashcards
1
Q
Describe Order Property for a heap.
A
In a heap, the parent node is always larger (in the
case of a maxheap) or smaller (in the case of a
minheap) than its children.
2
Q
Describe Shape Property for a heap.
A
A heap is always complete; at any point, each
level of the tree is completely filled, except for the
last level which may be filled from left to right with
no gaps
3
Q
At what index of a heap is the root stored?
A
index 1
4
Q
At what index is the left child of any node at index i?
A
2 * i
5
Q
At what index is the right child of any node at index i?
A
2 * i + 1
6
Q
At what index is the parent of a node at index i?
A
i / 2