All Exams Test series for 1 year @ ₹349 only
Question

Let us assume a person climbing the stairs can take one stair or two stairs at a time. How many ways can this person climb a flight of eight stairs?

The correct answer is

34

Understanding the Stairs Climbing Problem

This problem asks for the number of distinct ways a person can climb a flight of eight stairs, given that they can take either one stair or two stairs at a time. This is a classic combinatorial problem that can be solved using dynamic programming or by recognizing its connection to the Fibonacci sequence.

Developing a Strategy to Count Stair Climbing Ways

Let's denote the number of ways to climb \(n\) stairs as \(W(n)\). To reach the \(n\)-th stair, the person must have come from either the \((n-1)\)-th stair (by taking one step) or the \((n-2)\)-th stair (by taking two steps).

Therefore, the total number of ways to reach the \(n\)-th stair is the sum of the number of ways to reach the \((n-1)\)-th stair and the number of ways to reach the \((n-2)\)-th stair. This gives us a recurrence relation:

\[W(n) = W(n-1) + W(n-2)\]

This recurrence relation is the same as the one for the Fibonacci sequence. We need to define the base cases for this problem.

Identifying the Base Cases for Stair Climbing

  • For 1 stair: The person can only take one step of size 1. So, there is only 1 way. \(W(1) = 1\).
  • For 2 stairs: The person can take two steps of size 1 (1, 1) or one step of size 2 (2). So, there are 2 ways. \(W(2) = 2\).

Note that if we consider 0 stairs, there is 1 way (do nothing). \(W(0)=1\). Using the recurrence \(W(2)=W(1)+W(0)\), if \(W(1)=1\), then \(2=1+W(0)\) implies \(W(0)=1\). However, for practical counting from \(n=1\), \(W(1)=1\) and \(W(2)=2\) are the direct base cases derived from the problem statement.

Calculating the Ways to Climb Eight Stairs

Now we can use the recurrence relation \(W(n) = W(n-1) + W(n-2)\) and the base cases \(W(1)=1\) and \(W(2)=2\) to find the number of ways to climb up to 8 stairs.

  • \(W(1) = 1\)
  • \(W(2) = 2\)
  • \(W(3) = W(2) + W(1) = 2 + 1 = 3\) (Possible ways: 1+1+1, 1+2, 2+1)
  • \(W(4) = W(3) + W(2) = 3 + 2 = 5\) (Possible ways: 1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2)
  • \(W(5) = W(4) + W(3) = 5 + 3 = 8\)
  • \(W(6) = W(5) + W(4) = 8 + 5 = 13\)
  • \(W(7) = W(6) + W(5) = 13 + 8 = 21\)
  • \(W(8) = W(7) + W(6) = 21 + 13 = 34\)

So, there are 34 ways to climb a flight of eight stairs taking one or two stairs at a time.

Number of Ways to Climb Stairs
Number of Stairs (n) Number of Ways (W(n))
1 1
2 2
3 3
4 5
5 8
6 13
7 21
8 34

The number of ways to climb 8 stairs is 34.

Revision Table: Stair Climbing Problem

Key Concepts Reviewed
Concept Description
Problem Type Dynamic Programming / Combinatorial Counting
Steps Allowed 1 stair or 2 stairs at a time
Recurrence Relation \(W(n) = W(n-1) + W(n-2)\)
Base Cases \(W(1) = 1\), \(W(2) = 2\)
Result for 8 Stairs 34 ways

Additional Information: Dynamic Programming and Fibonacci Sequence

This stairs problem is a classic example of how problems with overlapping subproblems and optimal substructure can be solved efficiently using dynamic programming. The problem of climbing \(n\) stairs depends on the solutions for climbing \(n-1\) and \(n-2\) stairs. The solutions for smaller numbers of stairs (subproblems) are reused multiple times when calculating solutions for larger numbers of stairs (overlapping subproblems).

The sequence of the number of ways to climb stairs (1, 2, 3, 5, 8, 13, 21, 34, ...) starting from W(1) is essentially the Fibonacci sequence shifted. The standard Fibonacci sequence starts with \(F(0)=0, F(1)=1\), then \(F(2)=1, F(3)=2, F(4)=3, \dots\). In our case, \(W(n) = F(n+1)\), where \(F(n)\) is the standard Fibonacci sequence starting with \(F(1)=1, F(2)=1\). If we use the base cases \(F(0)=0, F(1)=1\), then \(W(n)=F(n+1)\).

  • \(F(1)=1 \implies W(0)=1\) (0 stairs, 1 way - do nothing)
  • \(F(2)=1 \implies W(1)=1\) (1 stair, 1 way)
  • \(F(3)=2 \implies W(2)=2\) (2 stairs, 2 ways)
  • \(F(4)=3 \implies W(3)=3\) (3 stairs, 3 ways)
  • \(F(9)=34 \implies W(8)=34\) (8 stairs, 34 ways)

This connection highlights the mathematical relationship between different seemingly unrelated problems and sequences.

Was this answer helpful?

Important Questions from Combinations

  1. How many ways are there to pack six copies of the same book into four identical boxes, where a box can contain as many as six books ?

  2. There are 9 different rock lizard species, each with a unique colour. Lizards of 2 different species sit on a rock at any given time. The number of possible colour combinations of rock lizards seen together on a rock is _________ 
    (Answer in integer)

  3. There are nine species of Impatiens (balsams) found in laterite plateaus of the northern Western Ghats, each with a distinct colour. If a plateau has exactly 6 species, then the number of possible colour combinations in the plateau is __________. (Answer in integer)
  4. The number of different possible ways of forming five intramolecular disulfide bonds with ten cysteine residues of a protein is ________
  5. A set of 4 parallel lines intersect with another set of 5 parallel lines. How many parallelograms are formed?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App