# assign3 - CS4311 Design and Analysis of Algorithms Homework...

This preview shows pages 1–2. Sign up to view the full content.

CS4311 Design and Analysis of Algorithms Homework 3 Due: 11:10 am, May 8, 2008 (before class) 1. (20%) There is a staircase with n steps. Your friend, Jack, wants to count how many different ways he can walk up this staircase. Because John is quite tall, in one move, he can choose either to walk up 1 step, 2 steps, or 3 steps. Let F k denote the number of ways John can walk up a staircase with k steps. So, F 1 = 1, F 2 = 2, F 3 = 4, and F 4 = 7. Derive a recurrence for F k , and show that F n can be computed in O ( n ) time. 2. Consider the following coin-taking game between Tom and Jerry. We start with two piles of coins, with x coins in the first pile and y coins in the second pile. They will take turn to remove coins from the pile. In each turn, they have three options: (i) remove any number of coins from the first pile, (ii) remove any number of coins from the second pile, or (iii) remove the same number of coins from both piles. In this game, the person loses if he cannot get any coin during his turn. For instance, suppose it is Tom’s turn, and the coins in the current piles are ( x, y ) = (5 , 5). In this case, if Tom now removes coins using the third option, he can make the piles (0 , 0) so that Jerry loses by not getting any coin in his next turn. If both Tom and Jerry plays cleverly, some combinations of ( x, y ) are always losing. For instance, (0 , 0) is a losing combination, and we can also show that (1 , 2) is a losing combi- nation as follows: Firstly, there are only 4 ways of removing the coins: (1) take 1 coin from pile 1; (2)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern