Question: Suppose you are designing and implementing the priority queue used by the process scheduler, which is a critical component of the operating system. One of
Suppose you are designing and implementing the priority queue used by the process scheduler, which is a critical component of the operating system. One of the important functionalities of the process scheduler is that it must allow the users to kill a living process. That means the priority queue must support the deletion of an item. Suppose you are using the binary max heap as the priority queue, which is physically stored in a 1-basedindexing array A, where A.length and A.heap_size represent the size of the array and the size of the heap, respectively. Design a time- and space-efficient algorithm that deletes a specific item from the binary max heap, so that the remaining is still a binary max heap. More precisely, you are asked to fill the following pseudo code function to delete A[i] from A, so that the remaining of A is still a binary max heap. Show the time complexity of your algorithm in terms of A.heap_size using the big-oh notation (make the bound as tight as possible), and explain why.
max_heap_delete(A, i)
{
}
(Hint: Be careful in your logic; consider all possibilities when you restructure the heap. )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
