the remove method :-
public remove(): This method removes a single instance of the specified element from this queue, if it is present
does the remove method work in O(1) ? if so
how does it find the specific element
as priority queue uses array and it is not sorted therefor we cannot use binary search and linear search is a costly operation.
how does it work?
PriorityQueue<String> queue = new PriorityQueue<String>();
// Use add() method to add elements into the Queue
queue.add("Welcome");
queue.add("To");
queue.add("Overflow");
queue.remove("To");
how does the remove method find "To" in the priorityqueue array {"Overflow","Welcome","To"} (not in sorted form)