Question: Hi, Im learning about amortized analysis. Im not sure what a) is asking for. There are the same number of operators in the functions so

Hi, Im learning about amortized analysis. Im not sure what a) is asking for. There are the same number of operators in the functions so wouldn't the sequences all be the same? If so, then wouldnt it just depend on what the k value is. Im not too sure how to get started on this and was wondering if a hint could be provided.
2. 14 Suppose that we have an array A1,2,..] (index starting at 1) that is sufficiently large, and supports the following two operations INSERT and PRINT-AND-CUT (where k is a global variable initially set to 0): 1 def INSERT (x) k=k+1 5 def PRINT-AND-CUT: 6 7 for i from 1 to k: print Alk] # integer division We define the cost of the above two operations as follows: The cost of INSERT is exactly 1 The cost of PRINT-AND-CUT is exactly the value of k before the operation is executed Now consider any sequence of n of the above two operations. Starting with k the following two techniques 0, perform an amortized analysis using (a) Use the aggregate method: First, describe the worst-case sequence that has the largest possible total cost, then find the upper-bound on the amortized cost per operation by dividing the total cost of the sequence by the number of operations in the sequence. (b) Use the accounting method: Charge cach inserted element the smallest amount of "dollars" such that the total amount charged always covers the total cost of the operations. The charged amount for each insert wll be an upper-bound on the amortized cost per operation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
