This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 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 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 be2....
View
Full
Document
This note was uploaded on 03/17/2008 for the course CSE 465 taught by Professor Furer,martinhu,wenhui during the Spring '07 term at Pennsylvania State University, University Park.
 Spring '07
 FURER,MARTINHU,WENHUI
 Data Structures

Click to edit the document details