由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - another MIT dp problem without answer on their website.
相关主题
请教一道算法题2D median problem
请教SQL问题说马工这个工作是青春饭,确实不假
热乎乎的Z家面经求教一个combination的问题,求好方法
一个算法题:Selecting median of three sorted arrays求教一道ms的题目
请教一个题,不太容易,要O(n)"简单的"linklist的问题
被一个面试题卡的泪流满面 SQL一个stack怎么sort
error of sql query in MS Access database两种DP
求推荐学习recursive 算法的资料判断一个linked list是不是palindrome
相关话题的讨论汇总
话题: n1话题: n2话题: exist话题: n3话题: items
进入JobHunting版参与讨论
1 (共1页)
b*******e
发帖数: 217
1
Bin Packing (Simplified Version). You have n1 items of size s1, n2 items of
size s2, and n3 items of size s3. You'd like to pack all of these items into
bins each of capacity C, such that the total number of bins used is
minimized.
b*******e
发帖数: 217
2
my solution:
Recursive Function
Assume i > n1+n2 (can do same for i <= n1 and i > n1 and <= n1+n2)
Exist(i, j, a, b, c) = Exist(i-1, j, a, b, c) || Exist(i-1, j-Si, a, b, c-1)
where i is the index of ith item, j is the total capacity occupied by items
selected, a is the number of S1 item selected, b is the number of S2 item
selected, and c is the number of S3 item selected. note a <= n1, b<=n2 and c
<=n3.
Find all Exist from Exist(0,0,0,0,0) to Exist(n1+n2+n3, C, n1, n2, n3).
(a) If there is a j <= C which makes Exist(n1+n2+n3, j, n1, n2, n3) == ture,
the total number of bin used is 1.
(b) If there is no j satifisy (a), check whethere there is a j > C && j <=2c
which makes Exist(n1+n2+n3, j, n1, n2, n3) == true, then total number of
bin used is 2.
(c) do the same, if there is a j > 2c && <=3C, tototal numbe bin used is 3.
(d) continue .... until you find the min number of bins needed.
Above recursive function only tell us the min number of pins.
Introducing an intermediate matrix to track how to allocate the items.

of
into

【在 b*******e 的大作中提到】
: Bin Packing (Simplified Version). You have n1 items of size s1, n2 items of
: size s2, and n3 items of size s3. You'd like to pack all of these items into
: bins each of capacity C, such that the total number of bins used is
: minimized.

d*s
发帖数: 699
3
Is bin packing NP-Complete?

of
into

【在 b*******e 的大作中提到】
: Bin Packing (Simplified Version). You have n1 items of size s1, n2 items of
: size s2, and n3 items of size s3. You'd like to pack all of these items into
: bins each of capacity C, such that the total number of bins used is
: minimized.

b*******e
发帖数: 217
1 (共1页)
进入JobHunting版参与讨论
相关主题
判断一个linked list是不是palindrome请教一个题,不太容易,要O(n)
豁出去了,决定怒刷100题被一个面试题卡的泪流满面 SQL
请教recursive backtracking问题的时间复杂度的分析error of sql query in MS Access database
MS a0, a1, ..., b0, b1... 问题求推荐学习recursive 算法的资料
请教一道算法题2D median problem
请教SQL问题说马工这个工作是青春饭,确实不假
热乎乎的Z家面经求教一个combination的问题,求好方法
一个算法题:Selecting median of three sorted arrays求教一道ms的题目
相关话题的讨论汇总
话题: n1话题: n2话题: exist话题: n3话题: items