Heap Flashcards
1
Q
How to get the parent, left child, right child?
A
Consider that the array starts at index 1:
to get the parent(int i): return i/2 left child: return 2*i right child: return 2*i+1
2
Q
What is a heap?
A
A heap is a method to represent a binary tree in the form of an array. It can considered as a min heap or max heap.
3
Q
Heap property?
A
for every node other than the parent node, A[parent(i)] >= A[i]