Question: Jenny has three array-based stacks, A , B , and C , such that A has capacity 5, B has capacity 7, and C has
Jenny has three array-based stacks, A, B, and C, such that A has capacity 5, B has capacity 7, and C has capacity 4. Initially, B is full, and A and C are empty. Unfortunately, the person who programmed the class for these stacks made the push and pop functions private. The only function Jenny can use is a static function, transfer(S,T), which transfers (by iteratively applying the private pop and push functions) elements from stack S to stack T until either S becomes empty or T becomes full
So, for example, starting from our initial configuration and performing transfer(B,C) results in
| S | Operation | Holding after the operation | ||
| A | B | C | ||
| 1 | T(B,C) | 0 | 3 | 4 |
Describe a sequence of transfer operations that starts from the initial configuration and results in B holding 4 elements at the end.
Initial configuration A = 0 B =7 C = 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
