![marshallmattah](/avatars/8283.jpg)
marshallmattah
02.03.2020 •
Mathematics
Consider an ordinary binary heap data structure with n elements that supports the instructions Insert and Extract-Min in O(log n) worst- case time. Give a potential function Φ such that the amortized cost of Insert is O(log n) and the amortized cost of Extract-Min is O(1), and show that it works.
Solved
Show answers
More tips
- H Health and Medicine Angina: Causes, Symptoms, and Treatment...
- H Health and Medicine What vaccines do children need?...
- H Health and Medicine Reasons for the Appearance of Warts: Everything You Need to Know...
- A Art and Culture How to Learn Screaming: Step-by-Step Guide for Beginners...
- H Health and Medicine Contraceptive Pills After 35: The Importance Of Choosing The Right Medication...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- C Computers and Internet How to Learn to Type Fast?...
Answers on questions: Mathematics
- M Mathematics (-2x+7) - (x+11) Can u please help...
- M Mathematics GUYS I RLLY NEED HELP I WILL MARK U BRAINLIEST...
- M Mathematics Decide if the following statement is valid or invalid. If it is sunny this week, then we will go to the park. We went to the park today, so it is sunny . True or False...
- M Mathematics ¿Cual es la masa fr un otro cubo de 3cm de lado, hecho del mismo material? ...
- M Mathematics Evaluate x to the second power -1 when x =-8 1) -7 2) 3 3) 63 4) 15...
- M Mathematics I need heeeelp please !...
- M Mathematics Y = - 4x y = 2x - 1which method is the best to solve this...
- M Mathematics Tim deposit 4500 in a savings account that pays 4.5% simple interest. How much interest does she earn into years?...
- M Mathematics Find the area. Simplify your answer. 2x 3x...
- M Mathematics Complete the description of how to model -4x + 6 = 23 you would use a negative a variable tiles and +1- tiles on one side of a line and +1 - tiles on the other side to represent...
Ответ:
It has been proved from the explanation below that the amortized cost of Insert is O(log n) and the amortized cost of Extract-Min is O(1),
Step-by-step explanation:
First of all, let's look at what "Extra-min" does;
It does the following ;
- Extract the root, (O1) actual time
- Replaces it with the last element x in the heap and repair the heap down or up.
- It takes O (Logn) time which is the depth of the heap.
Now, to get O(1) amortized time for extra-min, the last element "x" must have enough potential for repairing the heap and this potential must be in order of its depth.
Since we have K elements and so the weight of the kth element is WK in the heap as it's depth. So we can say;
WK = log k - - - - - - - - - eq (1)
Thus, the potential function Φ of the heap Hn for the n elements can be defined as ΦHn = Σ(WK) for k = 1 up till n. And so ΦHn will surely be greater than 0.
Thus; ΦHn = n(Logn)
Now let's check for insert ;
- pay actual cost of insert (logn)
-raise potential of the new elements
Now, using extra-min; O(1) amortized. To repair the heap, we'll use the potential of log(n) for the last element x as mentioned earlier.
In summary, when we use insert, potential increases and this can be afforded by paying insert more while when extra-min, potential decreases by a right moment of the cost of repairing.
Thus, we clearly see that Insert is O(log n) amortized and Extract-Min is O(1) amortized.
Ответ:
Linear
Step-by-step explanation:
If you graph this, you start at 1500 on the y-axis. Every time the x-axis increases by 1, the y-axis increases by 200. This forms a straight line, making it exponential since it increases by a constat amount.