Suppose we have a binary heap of n elements and wish to insert n more elements(not necessarily one after other). What would be the total time required for this?
I think it’s theta (n logn) as one insertion takes logn.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming we are given:
We have following insertion properties:
So for every case, we have
WorstCase is when, we insert new minimal value, so up-heap has to travel whole branch.
BestCase is when, for minimal-heap (heap with minimal on top) we insert BIG (biggest on updated branch) value (so up-heap stops immediately).
You’ve asked about series of n operations on heap containing already n elements,
it’s size will grow
what asymptotically is …
What simplifies our equations. (We don’t have to worry about growth of n , as it’s growth is by constant factor).
So, we have “for n insertions” of operation:
P.S. For displaying Theta Θ , Omega Ω symbols, you need to have UTF-8 installed/be compatible.