Recursion

Shared context
Complete all three blanks of a recursive C function move(n,A,B,C), whose printed central action moves disk n from pole A to pole C. B is the spare pole.
Answer & solution
Answer: Blanks: n > 0; n−1, A, C, B; n−1, B, A, C (no official key was published)
1. Infer the parameter roles from the printed central action. move(n,A,B,C) prints a move of disk n from A to C, so A is the source, C the destination, and B the spare pole. A recursive call must preserve this source/spare/destination order even when the pole names are permuted.
2. Fill the stopping condition. For zero disks there is nothing to move. Therefore execute the body only when n > 0. Using n > 1 would incorrectly skip the required single-disk move.
3. Clear the largest disk. Before disk n can move from A to C, the n−1 disks above it must move from A to B with C available as spare. In the function’s argument order this is move(n−1,A,C,B).
4. Move the largest disk, then restore the smaller tower above it. The printed action moves disk n from A to C. Next transfer the n−1 disks from B to C using A as spare, which is move(n−1,B,A,C).
5. The completed valid C function is:
void move(int n, char A, char B, char C)
{
if (n > 0) {
move(n - 1, A, C, B);
printf("Move disk %d from pole %c to pole %c\n", n, A, C);
move(n - 1, B, A, C);
}
}
Use the standard stdio declaration for printf in a complete program. The three blanks, in order, are n > 0; n−1,A,C,B; and n−1,B,A,C.
6. Check n=2 explicitly. The execution moves disk 1 A→B, disk 2 A→C, and disk 1 B→C. Each move is legal and the final tower is on C. For general n, assuming both smaller recursive transfers are legal establishes correctness by induction. The move count satisfies T(0)=0 and T(n)=2T(n−1)+1, hence T(n)=2n−1. Simulation verifies legality and final placement for n=1,…,8.