tomnebula
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I think the question here is not about how the binary heap works itself. The question is how we find the proper element to "feed" the heap after we take away its root. How can we tell which sorted array does the just taken element come from? You are using a dynamically updated hash map? I do not think it a good idea.
Btw, I think the complexity for a heap insertion should be O(1). In fact, most bubble-up in heap would end within 2 steps. You can turn to wiki about heap for more details.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Assume the size of int is n (bits), the largest number that can fit there is 2^(n) - 1.
- tomnebula February 10, 2014