Time complexity is logn, but here we also have to find that key and that will take maybe (n), so what about this?
Time complexity of deleting random element from heap
that is true.
to delete a random element, we need to first search the element which is O(n) complexity. so delete operation is O(n).
But in this question we presume that index of element is given, which skips searching part. thus reduces time complexity to O(logn).
thanks.
rate and resolve if satisfied.
thanks
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.