# Homework 6 CS 581 Algorithms, Spring 2016 ```Homework 6
CS 581 Algorithms, Spring 2016
1. A group of the local mafia is considering the establishment of a gaming house. The businessmen have
already purchased a building with a floor space limitation of 25 square yards. These men are considering
using four types of gambling. They include blackjack, poker, craps, and roulette. The estimated value per
table and space required is given as follows (estimated by the mafia’s financial wizards):
Game
Blackjack
(i = 1)
Poker
(i = 2)
Craps
(i = 3)
Roulette
(i = 4)
Space required
per table, Si
4
First Table
10
Second Table
7
Third Table
4
Fourth Table
1
5
9
9
8
8
6
11
10
9
8
3
8
6
4
2
It is important to note that the investors have realized that their marginal returns decrease for each game
as more tables are added. This indicates that the clientele may fill one roulette table all the time but a
second table might be idle for part of the time. Thus we have the varying values for each item (game).
Assume that at most 4 of each game can be used.
How many tables should be installed for each game in order to maximize profits? Solve the problem with
a dynamic programming formulation where stage 1 corresponds to the roulette decision, stage 2 to the
craps decision, stage 3 to the poker decision, and stage 4 to the blackjack decision. Thus s4 = 25. A state
variable denotes the number of square yards available. A decision variable specifies the number of tables
assigned. Return variables yield profit. Provide the following for your solution:
• The 4 tables (one for each game) that are constructed by the dynamic programming approach.
• The maximum profit that the gaming house can provide.
• The optimal combination of games that provides the maximum profit.
2. Exercise 15.3-3 in the book. Note that optimal substructure refers to the Principle of Optimality.
3. Does the Principle of Optimality apply to the problem of sorting? What allows divide and conquer sorting
algorithms to outperform the expected performance of a sorting algorithm based on dynamic programming?
4. Programming Assignment (Homework 7, Due Thursday, March 10): Problem 15-2 in the book.
Implement a dynamic programming algorithm to solve the problem as stated. Turn in your code (printed
out or as a PDF), and determine what the runtime complexity should be. Experimentally verify that your
algorithm indeed has this complexity (approximately) by timing it on inputs of varying size and fitting
a curve to the resulting data points. Also give the longest palindrome subsequence that your code finds
in the following statement of the Principle of Optimality by Richard Bellman from his book Dynamic
Programming (1957). Ignore whitespace and punctuation.
An optimal policy has the property that whatever the initial state and initial decision are, the
remaining decisions must constitute an optimal policy with regard to the state resulting from the
first decision
1
```