• retagged by
1,405 views
1 1 vote
Deleting any random element in heap would take n+logn or n+n?

1 Answer

0 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.

Position:
Show:

Related questions

1 1 vote
1 1 answer
135
135 views
GO Classes asked Aug 29
135 views
Consider Dijkstra's algorithm on a graph having $V$ vertices and $E$ edges.Suppose an indexed priority queue is not used.Instead, the tentative distances are stored only ...
0 0 votes
1 1 answer
472
472 views
Neeraj_patel asked Nov 14, 2024
472 views
What is the Time Complexity of the Dijkstra when it is using Adjacency list + Array (sorted or unsorted ) ? If it is O( V^2 + E ) then ,According to the General form of A...
0 0 votes
1 answers 1 answer
897
897 views
Mrityudoot asked Mar 7, 2024
897 views
For flag based approach in Bubble sort we can check first by a flag if the list is sorted or not in O(n), and if it is sorted, then no need to sort and the operation ends...