; Homework
Documents
User Generated
Resources
Learning Center
Your Federal Quarterly Tax Payments are due April 15th

# Homework

VIEWS: 2 PAGES: 3

• pg 1
```									                  Greedy Algorithms Homework

• Page 274:   2
• Page 318:   2
Homework, Page 274

2. Greedy coin changing with A = 37 and denominations 1,5,10,25
i=1
c = A/denom[i] = 37/25 = 1            Use 1 coin of denomination 25
A = A - c*denom[i] = 37 - 1*25 = 12
i = i+1= 2
c = A/denom[i] = 12/10 = 1            Use 1 coin of denomination 10
A = A - c*denom = 12 - 1*10 = 2
i = i+1 = 3
c = A/denom[i] = 2/5 = 0              Use 0 coins of denomination 5
A = A - c*denom = 2 - 0*5 = 2
i = i+1= 4
c = A/denom[i] = 2/1 = 2             Use 2 coins of denomination 1
Homework: Page 318
2 Solve the following continuous-knapsack problem

i       1      2      3     4
pi       4      3      6     8
wi      12     15     20     15                   Capacity = 50
pi/wi    1/3    1/5   3/10   8/15

Object indices in descending price/weight ration: 4,1, 3, 2
Choices:
all of 4, all of 1, all of 3, for a total weight of 15+12+20 = 47;
plus (3/15) of 2, for a total weight of 47 + (1/5)15 = 50
Profit: 18 + 16 + 14 + (1/5)4 = 18.4

```
To top
;