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

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

View Full Document Right Arrow Icon
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)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online