0

This post asks the following question:

You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

It also provides an answer:

Let $F_n$ be the number of ways to climb $n$ stairs taking only $1$ or $2$ steps. We know that $F_1 = 1$ and $F_2 = 2$. Now, consider $F_n$ for $n\ge 3$. The final step will be of size $1$ or $2$, so $F_n$ = $F_{n-1} + F_{n-2}$. This is the Fibonacci recurrence.

I don't understand the answer and here is why:

Suppose you are climbing $n$ stairs. In the end, you have to climb either $1$ stair or $2$ stairs.

  1. If you have to climb $1$ stair, then you've already climbed $(n-1)$ stairs, which contributes $F_{n-1}$ to the recurrence. After that, you still have to climb $1$ stair, which contributes $1$ to the recurrence (there is only one way to climb the remaining one stair).

  2. The case with $2$ remaining stairs is analogous: $F_{n-2}$ ways to climb $(n-2)$ stairs plus $2$ ways to climb the $2$ remaining stairs.

Therefore, the recurrence relation is: $F_n$ = $(F_{n-1} + 1) + (F_{n-2} + 2)$.

Can you please explain where I am wrong? More generally, I don't understand why we do not count the number of ways to climb the remaining stairs in the recurrence.

1 Answers1

1

Long comemnt

$F_n$ does not count the steps but the ways.

Base cases: (i) a stair case with only 1 stair: only one possibility: 1 step.

(ii) a stair case with 2 stairs: two possibilities: either one 2-stairs step or two one-stair steps.

Thus: $F_1=1$ and $F_2=2$.

Now, what happens with $F_3$ (three stairs)? As per linked answer, your last step can be either a 1-stais step, in which case you have already climbed two stairs, and we know that the possible ways are $F_2$.

Or your last step is a 2-stairs step, in which case you have already climbed only one stair, and we know that the possible ways are $F_1$. The added step does not add a new "way" to climb: we arrived there with a 1-stair step: this is the only way. Thus, in this case there is only one way: first step: one stair; second step: two stairs. And this is $F_1$.

Intuitively, you can count the ways: 1-1-1 and 2-1 (these are $F_2$) and 1-2 (this is $F_1$).