The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
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 in Algorithms by Veteran (112k points) | 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

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,782 questions
54,511 answers
188,329 comments
75,107 users