0 votes
115 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?
asked | 115 views

## 1 Answer

+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))
answered by Active (2.9k points)
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

Read question  an 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

0 votes
0 answers
1
+1 vote
0 answers
2
0 votes
0 answers
3
+1 vote
1 answer
5
+2 votes
1 answer
6
0 votes
0 answers
7