if you call the Heapify then for n element then it will take = O(n log n) time.

The Solution of this problem is

Take All the 2*n element and call the Build Heap().

So, It will take O(2n) = O(n) time.

The Gateway to Computer Science Excellence

0 votes

https://gateoverflow.in/459/gate2008-47

here if we insert all elements together and then call heapify function then it’ll take O(logn) time. why answer is O(n)?

- All categories
- General Aptitude 1.8k
- Engineering Mathematics 7.4k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.5k
- Others 1.7k
- Admissions 595
- Exam Queries 576
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 17

50,666 questions

56,131 answers

193,671 comments

93,309 users