In the class, we saw a special type of stacks in which eachoperation involves popping n ≥ 0 items followed by pushing exactlyone item. Consider a variant in which each operation involvespopping one item followed by pushing n ≥ 0 items. Assume the stackis implemented using an array of fixed size C and the number ofitems in the stack is never more than C. Use the potential functionmethod to show the amortized cost of each operation is at most2.
Expert Answer
An answer will be send to you shortly. . . . .