Consider these 2 questions where recurrence relations can be applied:
Q1) Given an (nxm) where n denotes rows and m denotes columns of a grid, find the number of unique paths ($a_{n,m}$) that goes from the top left corner of the grid to the bottom right corner of the (nxm) grid. Rule: Can only move downwards or rightwards when travelling on the grid
For Q1) the solution is as follows:
- Base Cases: when n or m is equals to 1 (i.e. $a_{1,m} =1 $ and $a_{n,1} = 1$)
- Considering the last action: There are 2 cases - 1) moving downwards 2) moving rightwards to reach the bottom left corner of the grid. Hence, the recurrence relation is of the form: $a_{n,m} = a_{n-1,m} + a_{n,m-1}$.
But notice here that there is a 1-1 correspondence between $a_{n,m}$ and ($a_{n-1,m} + a_{n,m-1}$) -- for every unique path in $a_{n-1,m}$ we move 1 grid downwards and for every unique path in $a_{n,m-1}$ we move 1 grid rightwards - doing so will create a 1-1 correspondence with the unique paths in $a_{n,m}$.
. .
Q2) The "Tower of Hanoi" Problem where the recurrence relation is of the form: $a_n = 2a_{n-1} + 1$ where $a_n$ denotes the minimum number of steps needed to move n disks from one bar to another bar
. .
Although Q1) seems to have a 1-1 function underneath its recurrence relation, I am wondering whether the same can be argued for the "Tower of Hanoi" problem as I am not able to think of it..
Yes, there is such a bijection.
Let's let $T_1$, $T_2$, $T_3$ denote the three Towers of Hanoi. A single play of the Tower of Hanoi game can be expressed as a finite sequence $p_1,...,p_I$ of ordered pairs $$p_i = (x_i,y_i) $$ where $x_i \ne y_i \in \{1,2,3\}$, where we interpret $p_i$ as take the top piece from $T_{x_i}$ and put it on top of $T_{y_i}$; of course the pieces are linearly ordered by size and the move is legal if and only if the piece moved is smaller than all of the current pieces on $T_{y_i}$. The length of the play $(p_1,...,p_I)$ is $I$.
Let's say that a single play of this game is an $(n,x,y)$-win if the game starts with $n$ pieces on $T_x$ and ends with $n$ pieces on $T_y$. An $(n,x,y)$-win is minimal if it has minimal length amongst all $(n,x,y)$-wins; let $a_n$ denote that minimal value (by symmetry, it is independent of $x,y$).
Here's what you have to prove by induction:
Once this has been proved, it immediately follows that $a_n = 2 a_{n-1} + 1$, because every minimal $(n,1,3)$ win starts with $a_{n-1}$ moves, followed by $1$ move, followed by $a_{n-1}$ moves.