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
The equation below represents the trend line of a scatter plot showing the hours spent studying versus science test scores.
navik [9.2K]

Answer:

On the science test  the point  ( 0 , 424 ) the intercepts is bigger

Step-by-step explanation:

The relation hours spend vs science test score is

y  =  6.5*x  + 424

And the relation hours spend vs Maths test score is

y  =  7.2*x   + 34.7

Making   x =  0  ( student does not study at all ) we get:

For science score test woul be

y  =  0  + 424

In case of maths

y  =  0  + 34.7

That mean student without studying will get better score in science.

The point  ( 0 , 424)   ( science ) represents the interception with y axis

in Maths case such point is  ( 0 . 34.7)

7 0
3 years ago
Read 2 more answers
If California has 6,480 residents and each resident produces about 182 cubic feet of garbage per year, how long can the landfill
svetoff [14.1K]

Answer:

0

Step-by-step explanation:

Just 4 people per year would overflow the landfill, how would it survive 6480 people?

5 0
4 years ago
Is -¼ + 2 ¼y + 2 - y equivalent to y + 2 ?
Juliette [100K]

Answer: No

Step-by-step explanation:

-\frac{1}{4}+2\frac{1}{4}y+2-y=y+2

(-\frac{1}{4}+2)+(2\frac{1}{4}y-y)=y+2\\

(\frac{(-1)+(4)(2)}{4})+(\frac{9}{4}y-y)=y+2

(\frac{-1+8}{4})+(\frac{(9)(1)-(4)(1)}{4} )y=y+2

(\frac{7}{4})+(\frac{9-4}{4} )y=y+2

(\frac{7}{4})+(\frac{5}{4})y=y+2

5 0
3 years ago
Mae Ling earns a weekly salary of 400 plus a 7% commission sales in a gift shop. How much would she make in a work week if she s
11111nata11111 [884]
Im pretty sure its 4,771 but id double check with a calculator

7 0
4 years ago
2c + 1 = -31.......................................
maksim [4K]

Answer:

c =  -16

Step-by-step explanation:

2c = -32

c =  -16

3 0
3 years ago
Read 2 more answers
Other questions:
  • An archeologist discovered two artifacts buried beneath the ground. She found the first artifact at an elevation of -8:2/7 meter
    9·2 answers
  • How to write the number 2,937,082 in expanded form
    12·2 answers
  • BRAINLIESTTT ASAP! MATH EXPERT PLEASE HELP ME :)
    12·2 answers
  • A data display appears skewed to the right so? A) most of the data will be located on the left side of the display B) there are
    7·1 answer
  • Which two sentences indicate a first-person point of view? 1 Shelley, our cat, always gets excited when Mrs. Peters visits us. 2
    15·1 answer
  • Jemina flips a disc of the type shown below: A disc with two layers is shown. The top layer is shaded in a darker shade of gray,
    10·1 answer
  • Write in slope intercept form<br> x intercept -4 ; y intercept 2
    9·1 answer
  • What is the interquartile range of this data set ?
    13·1 answer
  • Find the possible subsets of A = {a,b}​
    6·1 answer
  • PLEASE HELp
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!