821 views
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

1 Answer

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. 

selected by

Related questions

11.1k
views
1 answers
1 votes
Pranabesh Ghosh 1 asked Aug 30, 2016
11,078 views
Suppose we are sorting an array of ten integers using a some quadratic sorting algorithm. After four iterations of the algorithm's main loop, the array ... be selection sort.D) The algorithm is neither selection sort nor insertion sort.
606
views
2 answers
0 votes
Pranabesh Ghosh 1 asked Aug 30, 2016
606 views
Given an array of integers what is the worst case time complexity that would find pair of integers which are same?A) O(nlogn)B) O(n)C) O()D) O(nloglogn)
747
views
1 answers
4 votes
Pranabesh Ghosh 1 asked Aug 30, 2016
747 views
A min heap with 1000 elements is stored in an array. What is the maximum possible index number for 9th min element?A) 254B) 100C) 9D) 511
320
views
1 answers
0 votes
Pranabesh Ghosh 1 asked Aug 30, 2016
320 views
What is the time complexity to check whether an array is binary min heap or not?A) (n)B) (logn)C) (nlogn)D) (