CPS 130 Homework 16 Amortized Analysis

due Wed June 12th

Write and justify your answers in the space provided.^{1}

1. (CLRS 17.2-1) A sequence of stack operations is performed on a stack whose size never exceeds k. After everykoperations, a copy of the entire stack is made for backup purposes. Show that the cost of n stack operations, including copying the stack, is O(n) by assigning suitable amortized costs to the various stack operations.

1Collaboration is allowed, even encouraged, provided that the names of the collaborators are listed along with the solutions. Students must write up the solutions on their own.

2. A sequence of n operations is performed on a data structure. The ith operation costs i if i is a power of 2, and 1 otherwise. Using the accounting method, determine the amortized cost per operation.