Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the source peg name.
DSA C#
Console.WriteLine("Move disk from [1] to destination");
Attempts:
3 left
💡 Hint
Common Mistakes
Using the destination peg name instead of source.
Using the auxiliary peg name incorrectly.
✗ Incorrect
The source peg is named "source" in the print statement to indicate where the disk moves from.
2fill in blank
mediumComplete the recursive call to move n-1 disks from source to auxiliary peg.
DSA C#
Hanoi(n - 1, [1], aux, dest);
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping source and destination pegs.
Using the auxiliary peg as source incorrectly.
✗ Incorrect
The first argument after n-1 is the source peg, so it should be "source".
3fill in blank
hardFix the error in the base case condition to stop recursion when no disks remain.
DSA C#
if (n [1] 0) return;
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which only stops at exactly zero, missing negative values.
Using '!=' which causes infinite recursion.
✗ Incorrect
The base case should stop recursion when n is less than or equal to zero.
4fill in blank
hardFill both blanks to correctly move n-1 disks from auxiliary to destination peg.
DSA C#
Hanoi([1], aux, [2], source);
Attempts:
3 left
💡 Hint
Common Mistakes
Using n instead of n-1 for the number of disks.
Swapping source and destination pegs.
✗ Incorrect
We move n-1 disks from auxiliary to destination peg after moving the largest disk.
5fill in blank
hardFill all three blanks to complete the recursive Tower of Hanoi function call sequence.
DSA C#
Hanoi([1], [2], aux, [3]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using n instead of n-1.
Mixing up auxiliary and destination pegs.
✗ Incorrect
The recursive call moves n-1 disks from source to auxiliary peg before moving the largest disk to destination.
