I have a max PriorityQueue designed using a heap. A function removemax() that removes and returns the element with the largest priority in $\Theta(\log n)$ and a function insert in $\Theta(\log n)$ for the worst cases (both of them work with the heap by reorganizing it whenever necessary in order to retain the heap properties).I am designing a function to remove the second largest element in the queue.This is my algorithm assuing queue is a priority queue with the functions insert and removemax:removesecondlargest(queue)    largest = queue.removemax()    secondlargest = queue.removemax()    queue.insert(largest)    return secondlargestHowever, I am not sure why this approach isn't in $O(\log n)$ for the worst case?Can someone explain me why?
Why is removing the second largest element from a max-heap not in O(log n)?
algorithm analysis;data structures;asymptotics;heaps