Heap Tree Flashcards

1
Q

What are the types of heaps?

A

max-heaps and min-heaps

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

What are heaps mainly used for?

A

Heap sorts and priority queues

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

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

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

Height of a heap?

A

O(logn)

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

Visualized as an array, where is the root?

A

At index 1

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

Visualized as an array, where is the left child?

A

left(i) = 2*i

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

Visualized as an array, where is the right child?

A

right(i) = 2 * i +1

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

Visualized as an array, how to get to the parent?

A

parent(i) = floor(i/2)

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