0.0 Insert, FindMax, ExtractMax, IncreaseKey Flashcards
Give the function for the operation:
Insert(x, priority p)
M = M U {x}; x.key = p
Give the function for the operation:
element FindMax()
Give the function for the operation:
element ExtractMax()
x = FindMax(); M = M{x};
return x
Give the function for the operation:
IncreaseKey(x, priority p)
If x.key < p then x.key = p
Describe the NaIve implementation of the four operations?
Stored in an array, new elements appended to the end.
Maximum maintained.
What are the runtime complexities for the naIve implementation of these four operations?
Insert: O(1)
FindMax: O(1)
ExtractMax: O(n)
IncreaseKey: O(1)
Describe the heap implementation of the four operations?
Stored in a heap, new elements appended and sifted down.
Maximum always at root of heap.
What are the runtime complexities for the heap implementation of these four operations?
Insert: O(log(n))
FindMax: O(1)
ExtractMax: O(log(n))
IncreaseKey: O(log(n))