AMORTIZED ANALYSIS OF ABINARY COUNTER There aretwo types of Binary Counter:1.

     Aggregate Method2.     Accounting Method3.     Potential Method Accounting Method:  Ø Accounting method in a amortizedanalysis is a method which is based on accounting.Ø It is the easiest way to calculatethe amortized cost of an operation.Ø It is better than the aggregatemethod or potential method.Ø But this method do not give us aguarantee of obvious analysis.Ø This Method does not include anycomplexity.Ø Each operation in this method is assignedwith a amortized costØ The actual cost should be greaterthan the amortized cost.

Ø Different amortized costs beingassigned to multiple different amortized operations. Some working containamortized cost more or less than the actual cost.Ø When the cost exceeds from the actualcost of amortized operation. Then the specific objects is assigned with adifference in a data structure called credit.Ø If the amortized cost is less thanthe actual cost, then the credit is used to pay for those operations.

Ø Overall amortized cost of operationsshould be >= overall actual cost <> total credit should be >= 0.Ø The credit in the amortized analysisis linked with a data structure. ·       Theaccounting method itself includes two operations:1.     Stack Operation 2.     Binary Operation STACK OPERATION: The stack operation consists of threeoperations:1.

    Push2.    Pop3.    Multi-pops §  To learn the counting method ofamortized analysis , here is the example:Actual Costs: Push   1,Pop       1,Multi pop   min (a, p)       where ais argument given to the multi pop and p is size of a stackNow, the assigned amortized costPush   2,Pop      0,Multi pop 0,  Now we can see that , the amortized cost of multi pop is 0 whereas theactual cost was a variable , so the overall amortized cost of three operationis O(1). But the overall cost ofamortized operation is O(n).But sometimes the amortized cost can be change asymptotically.  Binary Counter Increment:The binary counter with the increment operation starts with zero.

Therunning time of increment operation is directly proportional to the no.of bitsflipped.      Example:Let us take an example of a Dollar bill to present each unit of cost.

               For amortized analysis , let charge anamortized cost of 2 dollars to set it to a 1 dollar. If the bit is set , wewill take 1 dollar out 2 dollars to pay actual bit , then we place the left bitas a credit. At the anyother time we can use that left 1 dollar , and our bitwill never reset to zero. We will just pay for the dollar reset bill. Thus thenumber of 1’s in the counter can never be negative neither the amount of creditcan be negative.

So for “n” increment operators the amount of total amortized costis O(n), in which actual cost is bound.    

Written by
admin
x

Hi!
I'm Colleen!

Would you like to get a custom essay? How about receiving a customized one?

Check it out