Question: n this problem we consider two stacks A and B manipulated using the following operations ( n denotes the size of A and m the
n this problem we consider two stacks A and B manipulated using the
following operations n denotes 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.
Assume that A and B are implemented using doublylinked lists such the P ushA and P ushB, as well as a
single pop from A or B can be performed in O time worstcase.
a points What is the worstcase running time of the operations M ultiP opA, M ultiP opB, and T ransf er
b points Define a potential function n m and use it to prove that the operations have amortized
running time O Make sure to show your work.
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
