Question: Consider two stacks A and B manipulated using the following operations ( n is the size of A and m the size of B )
Consider two stacks A and B manipulated using the following operations
n is the size of A and m the size of B:
P ushAx: Push element x on stack A
P ushBx: Push element x on stack B
M ultiP opAk: Pop mink n elements from A
M ultiP opBk: Pop mink m elements from B
T ransf erk: Repeatedly pop an element from A and push it on B until either k elements
have been moved or A is empty.
Your task is to
define a potential function Phi n m and use it to prove that the five operations have amor
tized running time O
determine the total cost of executing n of the operations PushA, PushB, and MultiPopA,
MultiPopB, and Transfer, assuming that stack A and B begin with s t objects and finish
with sn tn objects respectivel
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
