Question: Thakatau has three array-based stacks, A, B, and C, such that A has capacity 100, B has capacity 5, and C has capacity 3. Initially,
Thakatau has three array-based stacks, A, B, and C, such that A has capacity 100, B has capacity 5, and C has capacity 3. Initially, A is full, and B and C are empty. Unfortunately, the person who programmed the class for these stacks made the push and pop functions private. The only function Thakatau 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 conguration and performing transfer(A, C) results in A now holding 97 elements and C holding 3. Provide a sequences of transfer operations start from the conguration and results in B holding 4 elements at the end. NB: Provide your answer as a list of transfer operations, for example (no spaces): transfer(B, A): transfer(B, C), transfer(C, A): transfer(C, B): transfer(A, B): transfer (C, A) Answer: _____________________
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
