Question

What is the typical time complexity for removing the highest-priority element (using poll()) from a java.util.PriorityQueue with N elements?     import java.util.PriorityQueue;     public class HeapQuestion4 {         public static void main(String[] args) {             PriorityQueue pq = new PriorityQueue();             pq.add(10); pq.add(5); pq.add(20); // Assume pq contains N elements             pq.poll(); // What is the time complexity of this operation?         }     }

A O(1)
B O(log N)
C O(N)
D O(N log N)
E O(N^2)
Practice Next

Hey! Ask a query