2 votes 2 votes Suppose that an application have a huge number of insert operations, but only few delete max operations. Which priority-queue implementation would be most effective: A) Max heap B) unordered array C) ordered array D) Binary search tree Algorithms algorithms + – Pranabesh Ghosh 1 asked Aug 30, 2016 Pranabesh Ghosh 1 821 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply mcjoshi commented Aug 30, 2016 reply Follow Share Unordered Array. $O(1)$ -- Insertion $O(n)$ -- Deletion 0 votes 0 votes Pranabesh Ghosh 1 commented Aug 31, 2016 reply Follow Share cant we do using maxheap using O(logn) time? 0 votes 0 votes mcjoshi commented Aug 31, 2016 reply Follow Share extract_max() in max heap can be done in O(1) time but number of operations are very small. And Insertion takes $O(log(n))$ time in maxi-heap whereas number of operations are large in number. Read this. Hope it clears your doubt 0 votes 0 votes dd commented Aug 31, 2016 reply Follow Share Yes for few delete op, using max_heap is unreasonable. 0 votes 0 votes Please log in or register to add a comment.
Best answer 4 votes 4 votes There are four implementations for priority queue: Structure Insertion Extract-max Unordered list $O(1)$ $O(n)$ Ordered list $O(n)$ $O(1)$ Binary Search Tree $O(log\;n)$ $O(log\;n)$ Heap $O(log\;n)$ $O(log\;n)$ When there are large number of insertion operations, unordered list is preferable. visakh r answered Aug 31, 2016 • selected Aug 31, 2016 by Arjun visakh r comment Share Follow See 1 comment See all 1 1 comment reply cse23 commented Oct 14, 2016 reply Follow Share I aggree but for BST , insertion and extract max will take O(n) ryt? in worst case it will be left skewed or right skewed 0 votes 0 votes Please log in or register to add a comment.