Recall the Priority Queue ADT allows for the following operations: Insert. Extra
ID: 3864065 • Letter: R
Question
Recall the Priority Queue ADT allows for the following operations: Insert. Extract-Max. Change-Priority. Suppose we implement a priority queue using a sorted linked list, where Insert(priority, identifier) has the effect of adding a node with contents (identifier. priority), while maintaining the invariant that the list is sorted by priority. How fast can the basic priority queue operations be implemented using this particular data structure, assuming the priority queue contains n elements? Choose the tightest upper bounds on running time that apply. Insert: O (1) Extract-Max: O (1) Change-Priority: O (1) Insert: O (1) Extract-Max: O(n) Change-Priority: O (1) Insert: O (n) Extract-Max: O (1) Change-Priority: O(n) Insert: O (los n) Extract-Max: O(log n) Change-Priority: O(log n) Insert: O(n) Extract-Max: O (1) Change-Priority: O (1)Explanation / Answer
Yes, c is correct
Since the list is sorted by priority then in worst case scenario if priority of all the elements are same then it will take O(n) time to insert as well as changing the priority.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.