0.0 Insert, FindMax, ExtractMax, IncreaseKey Flashcards

1
Q

Give the function for the operation:

Insert(x, priority p)

A

M = M U {x}; x.key = p

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

Give the function for the operation:

element FindMax()

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

Give the function for the operation:

element ExtractMax()

A

x = FindMax(); M = M{x};
return x

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

Give the function for the operation:

IncreaseKey(x, priority p)

A

If x.key < p then x.key = p

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

Describe the NaIve implementation of the four operations?

A

Stored in an array, new elements appended to the end.
Maximum maintained.

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

What are the runtime complexities for the naIve implementation of these four operations?

A

Insert: O(1)
FindMax: O(1)
ExtractMax: O(n)
IncreaseKey: O(1)

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

Describe the heap implementation of the four operations?

A

Stored in a heap, new elements appended and sifted down.
Maximum always at root of heap.

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

What are the runtime complexities for the heap implementation of these four operations?

A

Insert: O(log(n))
FindMax: O(1)
ExtractMax: O(log(n))
IncreaseKey: O(log(n))

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