Question: Describe how to implement a Priority Queue, given the following restrictions/requirements: i. The PQ will store n > 0 elements (n is an input provided

 Describe how to implement a Priority Queue, given the following restrictions/requirements:

Describe how to implement a Priority Queue, given the following restrictions/requirements: i. The PQ will store n > 0 elements (n is an input provided to your PQ); ii. All the keys are integers within the interval [0, k] (k is an input provided to your PQ); iii. The operation insert (key,object) must run in O(1) time, in the worst case; iv. The operation removeMin() must run in O(k) time, in the worst case. Your PQ can use, internally, any combination of data structures we have seen during the course (array, stack, queue, vector, list, sequence, tree, heaps, linked lists, ...), but make sure to consider the cost for the chosen data structures. Make sure you a) Provide the pseudocode for the insert (key,object) operation; b) Provide the pseudocode for the removeMin) operation; c) Explain the time analysis for your algorithms; d) Provide a space analysis for your data structure e) Explain in which cases this solution is better than a heap (explain why); f) Explain in which cases this solution is worse than a heap (explain why) Describe how to implement a Priority Queue, given the following restrictions/requirements: i. The PQ will store n > 0 elements (n is an input provided to your PQ); ii. All the keys are integers within the interval [0, k] (k is an input provided to your PQ); iii. The operation insert (key,object) must run in O(1) time, in the worst case; iv. The operation removeMin() must run in O(k) time, in the worst case. Your PQ can use, internally, any combination of data structures we have seen during the course (array, stack, queue, vector, list, sequence, tree, heaps, linked lists, ...), but make sure to consider the cost for the chosen data structures. Make sure you a) Provide the pseudocode for the insert (key,object) operation; b) Provide the pseudocode for the removeMin) operation; c) Explain the time analysis for your algorithms; d) Provide a space analysis for your data structure e) Explain in which cases this solution is better than a heap (explain why); f) Explain in which cases this solution is worse than a heap (explain why)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!