# AMORTIZED the amortized cost. Ø Different amortized costs being

AMORTIZED ANALYSIS OF ABINARY COUNTER There aretwo types of Binary Counter:1.     Aggregate Method2.     Accounting Method3.     Potential Method Accounting Method:  Ø Accounting method in a amortized analysisis 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 isassigned with 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.

We Will Write a Custom Essay Specifically
For You For Only \$13.90/page!

order now

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 the actualcost was a variable , so the overall amortized cost of three operation is O(1). But the overall cost of amortizedoperation 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 , letcharge an amortized cost of 2 dollars to set it to a 1 dollar. If the bit isset , we will take 1 dollar out 2 dollars to pay actual bit , then we place theleft bit as a credit. At the anyother time we can use that left 1 dollar , andour bit will never reset to zero. We will just pay for the dollar reset bill.

Thus the number of 1’s in the counter can never be negative neither the amountof credit can be negative. So for “n” increment operators the amount of totalamortized cost is O(n), in which actual cost is bound.    AMORTIZED ANALYSIS OF ABINARY COUNTER There aretwo types of Binary Counter:4.     Aggregate Method5.     Accounting Method6.

Potential Method Accounting Method:  Ø Accounting method in a amortized analysisis 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 isassigned with 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:3.     Stack Operation 4.

Binary Operation STACK OPERATION: The stack operation consists of threeoperations:4.    Push5.    Pop6.    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 the actualcost was a variable , so the overall amortized cost of three operation is O(1). But the overall cost of amortizedoperation 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 , letcharge an amortized cost of 2 dollars to set it to a 1 dollar. If the bit isset , we will take 1 dollar out 2 dollars to pay actual bit , then we place theleft bit as a credit. At the anyother time we can use that left 1 dollar , andour bit will never reset to zero. We will just pay for the dollar reset bill.Thus the number of 1’s in the counter can never be negative neither the amountof credit can be negative.

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