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
There are 11 girls and 14 boys in Mrs. Smith's fourth grade class, as shown in the
WINSTONCH [101]
79% the second choice
8 0
3 years ago
Find m∠U.<br> Write your answer as an integer or as a decimal rounded to the nearest tenth.
Ilia_Sergeevich [38]

Answer:

∠U = 56.4

Step-by-step explanation:

We can use trigonometric functions to solve this

Here we are given the opposite side of ∠U as well as the adjacent side.

When dealing with the adjacent and opposite side we use sin

Sin = Opposite side / Adjacent side

Opp = 5 and adj = 6

So

Sin(U) = 5/6

* take the inverse sine of both sides *

arc(sin)(u) = u

arcsin(5/6) = 56.4 *( rounded to the nearest tenth )

∠U = 56.4

5 0
2 years ago
Read 2 more answers
Where would 3.8 go on the number line?
nata0808 [166]

Answer:

Between 3 and 4

Step-by-step explanation:

3 0
3 years ago
A ball is thrown from a height of 40 meters with an initial downward velocity of 5 m/s
arsen [322]

0=40-10t-5t^2

t^2+2t-8=0

(t+4)(t-2)=0

t=-4 (not a solution) or t=2

Answer: after 2 seconds

7 0
3 years ago
Let f(x) = 2x3 – 4x.<br> Find f(-2).
N76 [4]

Answer:

Step-by-step explanation:

f(x) = 2x^3 - 4x.....find f(-2).....so sub in -2 for x

f(-2) = 2(-2^3) - 4(-2)

f(-2) = 2(-8) + 8

f(-2) = -16 + 8

f(-2) = -8 <==

7 0
3 years ago
Read 2 more answers
Other questions:
  • Nh jah hyghhhhghhhhhhhhhjyfgjkpiuf?
    13·1 answer
  • 1/2 to the nearest present
    9·1 answer
  • What is the gcf of 19x^7 and 3x^5
    6·1 answer
  • Assume the following is a true statement:
    15·1 answer
  • What is the value of x in equation 6x + 2= 9x - 1?
    6·2 answers
  • You are constructing a triangular sail for a one-person sailboat. For support, a horizontal steel pole will run along the base o
    7·1 answer
  • What is the value of Y when x=3 if the equation of the regression line is y=3.8X+ 23.1
    8·1 answer
  • 85.
    7·1 answer
  • Diego is buying fruit at the store. Which costs less:
    10·2 answers
  • Drag the correct graph of each equation into the apace next to that equation to show how the output y-values change with changes
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!