106 views
For searching an element from heap,then delete it from heap

Why will it take O(n+log n) time and not O(n log n) time?

+1 vote
you just need to search it first, O(n) & then delete(swap it with last element and call heapify which will take log(n).

T(n) = O(n + log(n))
0
but why not nlogn?

I mean + means OR

but here both n and logn required. So, why not nlogn ?
+1

For searching an element from heap,then delete it from heap

searching take O(n) in heap and deletion take O(logn) right for single element.

O(n+logn)= O(n)

search one for loop one function + heapify another function inside main

+1

we are searching and deleting only a single element

and + means addition here, it is not RE.

+1
deleting n elements will take O(nlogn) ?
+3
Deleting $n$ elements will take $n \ * \ O(n+logn) \ = O(n^{2})$
0
oh yes, thanks

1
+1 vote