Exercise Lover

July 11, 2007

Exercises 16.2-7

Filed under: 16.2 — yuhanlyu @ 8:39 am

Sort A and B into decreasing order.

Exercises 16.2-6

Filed under: 16.2 — yuhanlyu @ 8:38 am

Select the median m of the v_i/w_i, and partition the items into three set A,B and C. A is greater then m, B is equal, C is less than m. If the summation W’ of A is less than W, then we should recursive solve the problem of (B+C, W-W’). If the summation W’ of A is greater than W, then we should recursive the problem (A, W).

Exercises 16.2-5

Filed under: 16.2 — yuhanlyu @ 8:34 am

Cover the points from left to right. We should cover as many as possible point as we can.

Exercises 16.2-4

Filed under: 16.2 — yuhanlyu @ 8:33 am

Drive to the farthest station as it can.

Exercises 16.2-3

Filed under: 16.2 — yuhanlyu @ 8:32 am

Take one item one at a time according to the order. If x can be taken, then take it.

Exercises 16.2-2

Filed under: 16.2 — yuhanlyu @ 8:30 am

Let c(i,k) be the optimal solution for first i objects into knapsack with size k. The recursive formula is c(i,k) = max( (c(i-1,k), c(i-1,k-w_i)+v_i).

Exercises 16.2-1

Filed under: 16.2 — yuhanlyu @ 8:28 am

Blog at WordPress.com.