Question

ANSWER MULTIPLE CHOICE What is the tightest(best) worst case runtime for retrieving the smallest element in...

ANSWER MULTIPLE CHOICE

What is the tightest(best) worst case runtime for retrieving the smallest element in a min heap?

a. O(n)

b. O(1)

c. O(log(n))

0 0
Add a comment Improve this question Transcribed image text
Answer #1

o(log(n))

min heap

Definition: A min-Max heap is a complete binary tree such that if it is not empty,each element has a data member called key.Alternating levels of this tree are min levels and max level,respectively.the root is on min level.

To add an element to a min-max heap perform following operations:
1. Append the required key to the array representing the min-max heap. This will likely break the min-max heap properties, therefore we need to adjust the heap. 2. Compare this key with its parent: 1. If it is found to be smaller (greater) compared to its parent, then it is surely smaller (greater) than all other keys present at nodes at max(min) level that are on the path from the present position of key to the root of heap. Now, just check for nodes on Min(Max) levels. 2. If the key added is in correct order then stop otherwise swap that key with its parent

Add a comment
Know the answer?
Add Answer to:
ANSWER MULTIPLE CHOICE What is the tightest(best) worst case runtime for retrieving the smallest element in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT