The box stacking game is as follows: you start with a stack of n boxes. Then you
ID: 3790183 • Letter: T
Question
The box stacking game is as follows: you start with a stack of n boxes. Then you make a sequence of moves; in one move you pick one stack and divide it into two smaller non-empty stacks. The game ends when you have n stacks, each containing one box. When you divide a stack into two stacks of sizes a and b, you get ab points. Your overall score is the sum of points you accumulate per move, from the starting position to when the game ends. What strategy should you follow to maximize your score? Define the potential p(S) of a stack S with k boxes to be k (k - 1)/2, and the potential of a set of stacks as the sum of the potentials of all its stacks. Show that, from the starting position the potential decreases with each move. Use induction on the number of moves.Explanation / Answer
#include <iostream>
using namespace std;
int main () {
// Local variable declaration:
int a = 10;
// do loop execution
LOOP:do {
if( a == 15) {
// skip the iteration.
a = a + 1;
goto LOOP;
}
cout << "value of a: " << a << endl;
a = a + 1;
}while( a < 20 );
return 0;
}
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.