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
Find a formula for the general term an of the sequence assuming the pattern of the first few terms continues.
never [62]

Answer:

ans : general term = (2n +8)/(4^n) * (-1)^n

3 0
2 years ago
A courtroom spectator merely looks at the defendant and says, “He’s guilty, i tell you.”
Zigmanuir [339]

Answer:

hes lyin prolly

Step-by-step explanation:

6 0
3 years ago
Read 2 more answers
Sweatshirt = $32 t-shirts = $14 ,
rodikova [14]
Cost of a sweatshirt = $32
Then
Cost of 14 sweatshirts = (32 * 14) dollars
                                     = 448 dollars
Cost of a t-shirt = $14
Cost of 32 t-shirts = (32 * 14) dollars
                               = 448 dollars
So it can seen from the deduction that the cost of 14 sweatshirts and 32 t-shirts comes out to be same and equal to $448. I hope the answer and the procedure of doing this problem is clear to you. It is important to look at all the details given in the question and then start solving the problem.
4 0
3 years ago
Read 2 more answers
What is 299,864 times 5?
irakobra [83]

Answer:

1,498,420

Step-by-step explanation:

6 0
3 years ago
Choices are associative property and commutative property opposite of a sum property
grin007 [14]
It would be associative property because the order of the numbers stayed the same
3 0
3 years ago
Other questions:
  • DOES SOMONE KNOW HOW TO DO THIS???????
    6·1 answer
  • Please help me solve this
    12·1 answer
  • You have a 10kg bag of sand. the mass of a grain of sand is about 10 to the -3 power gram. about how many grains of sand are in
    9·1 answer
  • 1 MP Reason There are 12,600 insects on display at the new
    11·1 answer
  • The lengths of the legs of a right triangle are 6 cm and 3 cm.
    6·1 answer
  • What is 4 multiplied by 4 ?
    9·2 answers
  • Sara can finish 5 laps around the track in 6 minutes. What is her average speed in miles per hour, if it takes 12 laps around th
    8·1 answer
  • What is the slope-intercept equation for this
    7·1 answer
  • If Chang jogs one lap around the inside track, how far does he jog​
    14·2 answers
  • Helppp hurryyyy<br> i don’t understand it
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!