...
Question 14308 – Database-Management-System
December 19, 2023
Question 14283 – Digital-Logic-Design
December 20, 2023
Question 14308 – Database-Management-System
December 19, 2023
Question 14283 – Digital-Logic-Design
December 20, 2023

Question 9186 – Data-Structures

We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is

Correct Answer: B

Question 60 Explanation: 
Inserting an element into binary(either max or min) heap takes O(logn) for all cases, but in question they clearly mentioned that n elements and inserting one by one n elements, so it takes 2n time. So, O(n).
Note: We can also insert all the elements once, there will be no difference on time complexity.
A
θ(log n)
B
θ(n)
C
θ(nlog n)
D
θ(n2)
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!