Question bank › Recursion
Dsa Recursion Easy

Tower of Hanoi Variation

You have three pegs and n disks of different sizes that can slide onto any peg. The objective of this problem is to move all disks from the first peg to the last peg using a specific recursive approach. You can only move one disk at a time, and you cannot place a larger disk on top of a smaller disk. Input Format: An integer n (1 <= n <= 20). Output Format: A list of moves, where each move is represented as a tuple (from_peg, to_peg). Example: Input: 2 Output: [(1, 3), (1, 2), (3, 2)]

Key concepts

recursionbacktrackingmathematical

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.