but why not nlogn?

I mean + means OR

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

I mean + means OR

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

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

0 votes

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?

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))

T(n) = O(n + log(n))

+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`

- All categories
- General Aptitude 1.6k
- Engineering Mathematics 7.3k
- Digital Logic 2.7k
- Programming & DS 4.9k
- Algorithms 4.2k
- Theory of Computation 5.4k
- Compiler Design 2.1k
- Databases 4k
- CO & Architecture 3.5k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.5k
- Admissions 570
- Exam Queries 566
- Tier 1 Placement Questions 23
- Job Queries 70
- Projects 18

48,756 questions

52,850 answers

183,548 comments

68,742 users