Thakatau has three array-based stacks, A, B, and C, such that A has capacity 100
ID: 3886952 • Letter: T
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, 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: _____________________Explanation / Answer
Explanation::
Answer::
transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,C);transfer(A,B)
Thank you!!
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.