{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DS-chapter11&iuml;&frac14;ˆAmoritized Analysis)

DS-chapter11&iuml;&frac14;ˆAmoritized Analysis) -...

This preview shows pages 1–4. Sign up to view the full content.

CHAPTER 11 Amortized Analysis m Splay tree vs. AVL tree; skew heap vs. leftist heap Target : Any M consecutive operations take at most O( M log N ) time. -- Amortized time bound worst-case bound amortized bound average-case bound

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
§2 Binomial Queues H Claim m A binomial queue of N elements can be built by N successive insertions in O(N) time. The worst case time for each insertion is ? O ( log N ) Proof 1: B 0 /*step = 1 */ B 1 /*step = 1, link = 1 */ B 1 B 0 /*step = 1*/ B 2 /*step = 1, link = 2 */ B 2 B 0 /*step = 1*/ B 2 B 1 /*step = 1, link = 1*/ B 2 B 1 B 0 /*step = 1*/ B 3 /*step = 1, link = 3*/ B 3 B 0 /*step = 1*/ … … … Total steps = N Total links = ) ( ...) 16 1 3 8 1 2 4 1 ( N O N = + × + × + +1 +0 +1 –1 +1 –2 Expensive insertions remove trees, while cheap ones create trees.
Proof 2: §2 Binomial Queues An insertion that costs c units results in a net increase of 2 c trees in the forest. C i ::= cost of the i th insertion T i ::= number of trees after the i th insertion ( T 0 = 0)

This preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: T i-1 ) = 2 for all i = 1, 2, …, N Add all these equations up N T T C N N i i 2 1 =-+ ∑ = ) ( 2 2 1 N O N T N C N N i i = ≤-= ∑ = T worst = O (log N ), but T amortized = 2 §2 Binomial Queues T actual + ∆ Potential = T amortized Savings Account If an operation uses less than its allotted time, the unused time is saved in the form of a higher potential , for use later on by more expensive operations. In the case of the BuildBinomialQueue routine, the potential function can be taken as the number of trees . Note: While T actual varies from operation to operation, T amortized is stable . In general, a good potential function should • Always assume its minimum at the start of the sequence (e.g. start from 0 and is always nonnegative). • Cancel a term in the actual time....
View Full Document

{[ snackBarMessage ]}