So i have a CUSTOM PriorityQueue(implemented using a max-heap) containing songs. Each song is an object that has a number of likes, the name of the song and a unique ID. The priority of each song inside the PriorityQueue is defined as the number of likes it has and if two songs have the same number of likes then the name of the song is compared.
I am asked to create a "remove" function that takes as an argument the ID of the song and removes it from the PriorityQueue. The problem is that i have to search for the song that has this particular ID in order to remove it which happens in O(n), since it is a linear search. I am supposed to make the remove function in O(logn) but from what i have read i understand it is impossible to search in an unsorted array in less than O(n)... can someone offer any ideas?
(the hint that we have is that we may have to add some things inside the getMax function (getMax returns the root of the PQ which contains the most popular song) and the insert function).