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
Figure A is a scale image of figure B
serious [3.7K]
X=36

Divide the corresponding side (16) by 4/7
5 0
4 years ago
What two dimensional figure will be created by a horizontal cross section
andre [41]
A.) square pyramid.
8 0
3 years ago
Read 2 more answers
ABC is the image of ABC under a translation
morpeh [17]
The translation is (x-8,y+5). To get from A to A’ you go left (x-axis) 8 times and up (y-axis) 5 times.
8 0
3 years ago
F(x)=-4x^2+9 Find f(−3)
pochemuha

Answer:

f (-3) = 45

Step-by-step explanation:

f (x) =

4x {}^{2}  + 9

f (-3) =

(4 \times  - 3 \times  - 3) + 9

=》

36 + 9

=》

45

8 0
3 years ago
Really need a definite correct answer on this
cluponka [151]
Third choice is correct hope I helped:3
6 0
3 years ago
Other questions:
  • One angle of an isosceles triangle measures 90°. Which other angles could be in that isosceles triangle?
    7·2 answers
  • For the linear equation 5x+4y=16, express y in terms of x.
    15·1 answer
  • How tall would I  be if i were 54 inches   How tall would I be if i were 58 inches?   How tall would i be if Iwere 59 inches?
    13·1 answer
  • A triangle has two sides of lengths 6 and 9. What value coul the length of the third side be?
    10·2 answers
  • Claire’s bedroom measure’s 16 feet by 18 feet. If the purple carpet that she wants to buy costs $3.59 per square foot, what will
    8·2 answers
  • What is the measure of angle 1
    14·1 answer
  • Which expression is equivalent to m 2 - 13 m -30?
    12·1 answer
  • You buy a used car for $9,000. The car depreciates 9% per year. Find the value of the
    9·1 answer
  • The table below shows the amount of money Michelle has
    5·1 answer
  • Ok talk<br><br> here if you all<br> want
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!