Question

Consider the following Java code snippet:     import java.util.PriorityQueue;     public class HeapQuestion9 {         public static void main(String[] args) {             PriorityQueue pq = new PriorityQueue();             pq.add(10);             pq.add(5);             pq.add(20);             pq.add(3);             pq.add(15);             boolean removed = pq.remove(20); // Remove a specific element             System.out.println(removed);             System.out.println(pq.poll());         }     }     What will be the output of this program, and what is the typical time complexity of the pq.remove(20) operation?

A true, 3; O(log N)
B true, 5; O(N)
C true, 3; O(N)
D false, 3; O(log N)
E true, 5; O(log N)
Practice Next

Hey! Ask a query