retagged by
523 views
1 votes
1 votes
Deleting any random element in heap would take n+logn or n+n?
retagged by

1 Answer

0 votes
0 votes

The deletion of random element takes 0(n) + 0(logn) time.

0(n) as the array traverses to find the last element and assign it to the root;

0(logn) as the element swaps as per max/min heap condition and deletion takes for the root.

Related questions

0 votes
0 votes
0 answers
3
0 votes
0 votes
0 answers
4
Sajal Mallick asked Nov 27, 2023
171 views
As we have to select maximal set of “non overlapping” activities. So like job scheduling algo of greedy we can solve it. So according to that complexity must be O(n l...