# Dynamic - Dynamic Programming Practice Questions These...

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

Dynamic Programming Practice Questions These questions are NOT to turn in; they are just for your practice. Question 1. (This is similar to the “sticks” problem presented in class.) Consider a two- player game in which players make consecutive moves. There are 21 sticks in a pile. At each turn, a player may take one, two, four, or seven sticks from any one pile. Whoever takes the last stick loses the game. Use dynamic programming to determine from which states you can win this game, and from which states you can force your opponent to lose. Hint: you know that if there’s 1 stick left, you will lose. So “1 stick remaining” is a losing state. Can you figure out some easy winning states from there? Continue working backwards until you get to 21. Question 2. (This is similar to the telephone line example presented in class.) Homer loves doughnuts, and wishes to purchase exactly 17 doughnuts. At the Qwik-E-Mart, Homer can buy one doughnut for \$0.50, a pack of three doughnuts for \$1.20, and a pack

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 ]}

### Page1 / 2

Dynamic - Dynamic Programming Practice Questions These...

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

View Full Document
Ask a homework question - tutors are online