AmortizedAnalysis

b 3 4 1 2 c 4 6 2 3 k4 a499

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: 3 4 1 ? 2 ? ? C[ ] 4 6 2 3 ? ? ? ? k=4 A[4]=99, A[6]=33, A[2]=22, and A[3]=55 initialized in that order 6 Appetizer Theorem. A[i] is initialized iff both 1 ≤ B[i] ≤ k and C[B[i]] = i. Pf. ⇐ ・Suppose A[i] is uninitialized. ・If B[i] < 1 or B[i] > k, then A[i] clearly uninitialized. ・If 1 ≤ B[i] ≤ k by coincidence, then we still can't have C[B[i]] = i because none of the entries C[1.. k] can equal i. ▪ 1 2 3 4 5 6 7 8 A[ ] ? 22 55 99 ? 33 ? ? B[ ] ? 3 4 1 ? 2 ? ? C[ ] 4 6 2 3 ? ? ? ? k=4 A[4]=99, A[6]=33, A[2]=22, and A[3]=55 initialized in that order 7 A MORTIZED A NALYSIS ‣ binary counter ‣ multipop stack ‣ dynamic table Copyright © 2013 Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated on Sep 8, 2013 7:00 AM Amortized analysis Worst-case analysis. Determine worst-case running time of a data structure operation as function of the input size. can be too pessimistic if the only way to encounter an expensive operation is if there were lots of previous cheap operations Amortized analysis. Determine worst-case running t...
View Full Document

This document was uploaded on 02/05/2014.

Ask a homework question - tutors are online