Exercise 2: Dynamic Array Doubling for n=32 — Possible Solution ==================================================================== GIVEN ------------------------------ 32 appends, starting from capacity 1, doubling capacity at each resize (per this chapter's own method). STEP 1: THE RESIZE EVENTS AND THEIR COPY COSTS ------------------------------ Capacity 1 -> 2: copy 1 element Capacity 2 -> 4: copy 2 elements Capacity 4 -> 8: copy 4 elements Capacity 8 -> 16: copy 8 elements Capacity 16 -> 32: copy 16 elements Total copy cost: 1 + 2 + 4 + 8 + 16 = 31 STEP 2: THE ELEMENT-PLACEMENT COST ------------------------------ Every one of the 32 appends also does the actual O(1) work of placing the new element itself: 32 placements. STEP 3: TOTAL OPERATIONS ------------------------------ Total = 31 (copying) + 32 (placements) = 63 STEP 4: THE AMORTIZED COST PER APPEND ------------------------------ 63 / 32 ~= 1.97 operations per append This is consistent with this chapter's own finding that the amortized cost per append hovers around a small constant (roughly 2) regardless of n - matching the chapter's own n=16 (1.94), n=100 (2.27), and n=1000 (2.02) results closely. WHY THIS WORKS AS AN ANSWER ------------------------------ Each resize event's own copy cost is listed individually rather than computed as a single lump sum, the placement cost is added separately, and the final amortized figure is compared directly against this chapter's own previously reported results at other values of n to confirm the O(1) amortized pattern holds here too.