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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

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

Heap property?

A

for every node other than the parent node, A[parent(i)] >= A[i]

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