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]
2 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]2 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 multiplied by 3 equals 15 but added by 3 equals 18
Ivenika [448]

Answer:

15

Step-by-step explanation:

8 0
3 years ago
Read 2 more answers
how many leaves on a tree diagram are needed to represent all possible combinations tossing a coin 3 times
Lelechka [254]
I believe you would do 2 times 3, which gives you 6. 3 is for the number of coin tosses, and 2 is the number of sides of a coin.
6 0
2 years ago
Cuánto es 2/4<br><img src="https://tex.z-dn.net/?f=2%20%5Cdiv%204" id="TexFormula1" title="2 \div 4" alt="2 \div 4" align="absmi
katovenus [111]

Answer: 1/2 o .5

Step-by-step explanation:

5 0
2 years ago
Read 2 more answers
The volume of a rectangular prism is 5058 cubic inches.
astra-53 [7]

Answer:

412in

Step-by-step explanation:

5 0
2 years ago
What is Index Law 2?<br> please give definition
ioda

LAW 2: The second law of indices tells us that when dividing a number with an exponent by the same number with an exponent, we have to subtract the powers. In algebraic form, this rule is as follows . The a represents the number that is divided by itself and m and n represent the powers.

6 0
3 years ago
Read 2 more answers
Other questions:
  • The fraction represented in(1) is equivalent to the fraction represent in 1 (b)
    5·1 answer
  • Find the unit rate for 344 miles in 11 hours.
    12·2 answers
  • What is the number between minus 4 and 5​
    7·1 answer
  • In a 30-60-90 triangle, the length of the hypotenuse is 17. Find the length of the side opposite the 30 degree angle.
    6·1 answer
  • Write 1/10 as a percent
    7·2 answers
  • PLEASE HELP, ILL GIVE YOU 15
    11·1 answer
  • 2. Write a problem that matches: Bob has 20 pogs. He keeps 4 for himself and then equally divides the rest among his 4 brothers.
    6·2 answers
  • Evaluate.<br> (-2 1/4) to the second power<br> •khan academy<br> •10 points
    13·2 answers
  • three miners esch dup up 3 diamonds. the weight of the diamonds were 5,13,12,4,9,8,15,210, and 6 ounces of a piece. each of jack
    5·1 answer
  • The equation d=m/v can be used to calculate the density, d, of an object with mass, m, and volume, V. Which is an equivalent equ
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!