AmortizedAnalysis

Starting from the initial data structure d0 the total

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Initial data structure D0 starts with zero credits. Key invariant. The total number of credits in the data structure ≥ 0. n n ci ˆ i=1 ci 0 i=1 Theorem. Starting from the initial data structure D0, the total actual cost of n n i=1 i=1 any sequence of n operations is at most the sum of the amortized ci . ▪ costs. ci ˆ Pf. The amortized cost of the sequence of operations is: Intuition. Measure running time in terms of credits (time = money). 17 Binary counter: accounting method Credits. One credit pays for a bit flip. Invariant. Each bit that is set to 1 has one credit. Accounting. ・Flip bit j from 0 to 1: charge two credits (use one and save one in bit j). increment 7 6 5 4 3 2 1 0 0 1 0 0 1 1 1 1 0 18 Binary counter: accounting method Credits. One credit pays for a bit flip. Invariant. Each bit that is set to 1 has one credit. Accounting. ・Flip bit j from 0 to 1: charge two credits (use one and save one in bit j). ・Flip bit j from 1 to 0: pay for it with saved credit in bit j. in...
View Full Document

Ask a homework question - tutors are online