1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Elza [17]
3 years ago
11

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.
Mathematics
1 answer:
Ierofanga [76]3 years ago
7 0

Answer:

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.

You might be interested in
What is m&lt;4+ m&lt;5+ m&lt;6?<br> 180°<br> 270°<br> 300°
pickupchik [31]

I really think it is 180

8 0
3 years ago
What is the mean of 2,3?
iragen [17]
The answer is 2.5. :)


6 0
3 years ago
What does 9 yards times 3 feet times $2 equal?
disa [49]
54 is the answer to your question
3 0
3 years ago
You have are fat<br> a) YES<br> b) no
alina1380 [7]
No but are you fat ???
8 0
3 years ago
4z+27+5x=14y
MariettaO [177]

In order for the equation to work, x must be odd. Trying different values of x, we find 5 solutions:

(x, y, z) = (1, 4, 6), (3, 5, 7), (5, 6, 8), (7, 5, 2), (9, 6, 3)

Then the product xyz could be any of 24, 105, 240, 70, or 162.

4 0
3 years ago
Other questions:
  • A yearbook publishing company charges $50 for every yearbook printed and
    12·1 answer
  • if you can draw a number line that shows the relationship between tons and pounds, what would it look like? Explain
    8·1 answer
  • Lilly has $35,she went to the store and spender 10% of it,how much money she has left?
    11·2 answers
  • A meter is a unit of length approximately equal to 39.37 inches. If someone is 1.64 meters​ tall, what is his or her approximate
    11·1 answer
  • A piece of paper is in the shape of a rectangle the piece of paper is 1 5/8 inches wide and 8 3/4 inches long a student cuts of
    8·1 answer
  • Clara created the poster shown below:
    9·1 answer
  • Solve the equation.<br><br> 23=z15
    13·1 answer
  • Select all the options below that correctly fill in the blank. A ____ is a subcategory of polygon.
    15·1 answer
  • TO GET BRAINLIEST YOU NEED TO ANSWER ALL 3 QUESTIONS
    10·1 answer
  • Helppp!! Find the volume of the cone
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!