CSE 260
SOLUTIONS TO YELLOW QUIZ 9
Spring 2007
1. [7 points] Let
c
n
be the number of ways you can climb a staircase of
n
stairs if you can climb two or three
stairs with each step that you take. Thus, for example,
c
1
= 0 and
c
2
= 1. Write a recurrence relation for
c
n
and use it to find how many ways there are to climb a staircase of 20 stairs.
Show your work neatly.
For
n
≥
4, your trip up the staircase can consist of a first step that climbs two stairs followed by any of
the
c
n

2
ways of climbing the remaining stairs, or a first step that climbs three stairs followed by any of
the
c
n

3
ways of climbing the remaining stairs. Since there is no way to climb one stair and one way to
climb two or three stairs, we have the following recurrence relation and initial conditions.
c
1
= 0
, c
2
= 1
, c
3
= 1
,
and
c
n
=
c
n

2
+
c
n

3
for
n
≥
4
n
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
c
n
0
1
1
1
2
2
3
4
5
7
9
12
16
21
28
37
49
65
86
114
2. [7 points] On the homework, you analyzed a modified Tower of Hanoi problem in which a disk can only be
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '07
 FURER,MARTINHU,WENHUI
 Data Structures, Recursion, Stairway, Recurrence relation, Green Day, Billie Joe Armstrong

Click to edit the document details