请教一个算法的问题
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 13 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:noah (等级:8 - 融会贯通,发帖:753) 发表:2006-02-27 19:01:55  楼主  关注此帖
请教一个算法的问题
一个junior问我一个算法的问题,可是我的算法是用英文学的,看不懂他的题干。哪位曾经用中文学过算法的朋友帮个忙吧。谢谢~~

请考虑装箱问题的贪婪算法,他也被称为优先容纳算法(first-fit,FF):按照每个物
品给出的顺序,把它装入第一个能够容纳它的箱子;如果这样的箱子不存在,就把该物
品放在一个新箱子里,并将该箱子房子箱子列表的尾部。

1)证明FF算法是一个2近似的算法

装箱问题还有一个降序优先容纳算法(first-fit decreasing,FFD):它在开始的时候
,对物品按照体积的降序进行排序,然后再执行有限容纳算法。

2)这是个几近似算法?证明之。

题目来源:
(美)Anany Levitin
Introdution to The Design and Analysis of Algorithms
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:奕丫 (等级:4 - 马马虎虎,发帖:308) 发表:2006-02-27 21:32:58  2楼
先问一个问题:
这个是不是类似于我们常见的背包问题。
就是说,小偷偷东西,发现有N件,第I件价值Vi元,重Wi千克。都是证书。那么他希望带走越值钱的东西。但是背包里面只能容纳W千克。
怎么办呢?
是不是这种问题?因为我印象我们当时用贪心算法。
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:奕丫 (等级:4 - 马马虎虎,发帖:308) 发表:2006-02-27 21:40:32  3楼
装箱问题 ?
有一个箱子容量为v(正整数,o≤v≤20000),同时有n个物品(o≤n≤30),每个物品有一个体积 (正整数)。要求从 n 个物品中,任取若千个装入箱内,使箱子的剩余空间为最小。
[样例]
输入:
24 一个整数,表示箱子容量
6 一个整数,表示有n个物品
8 接下来n行,分别表示这n个物品的各自体积。
3
12
7
9
7
输出:
0 一个整数,表示箱子剩余空间。
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:奕丫 (等级:4 - 马马虎虎,发帖:308) 发表:2006-02-27 21:41:49  4楼
装箱问题 ? 有一个箱子容量为v(正整数,o≤v≤20000),同时有n个物品(o≤n≤30),每个物品有一个体积 (正整数)。要求从 n 个物品中,任取若千个装入箱内,使箱子的剩余空间为最小。 [样例] 输入: 24 一个整数,表示箱子容量 6 一个整数,表示有n个物品 8 接下来n行,分别表示这n个物品的各自体积。 3 12 7 9 7 输出: 0 一个整数,表示箱子剩余空间。
传说中用动态规划...晕了,两年没看过了
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:马甲甲甲 (等级:6 - 驾轻就熟,发帖:1503) 发表:2006-02-27 23:18:00  5楼 评分:
approximation algorithm
This bin-pack problem is extensively used as an example for approximation algorithms in NP-complete problems. You should be able to find the explainations and proofs (for both FF and FFD) in a reasonable college computer algorithm textbook, under NP-complete section, but it might not be covered in an undergraduate algorithm course.

Briefly put, given an optimal solution of value O to an NP problem, and an approximation algorithm (in polynomial time) that outputs a solution that is k*O on average, then this approximation algorithm is called a k-approximation.

If I remember correctly, FFD is an 3/2 approximation algorithm.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:Bird (等级:5 - 略有小成,发帖:759) 发表:2006-02-28 00:04:15  6楼
你是请教新生,还是混充新生请教?
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:noah (等级:8 - 融会贯通,发帖:753) 发表:2006-02-28 00:21:13  7楼
你是请教新生,还是混充新生请教?
我帮新生请教
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:noah (等级:8 - 融会贯通,发帖:753) 发表:2006-02-28 00:25:34  8楼
你是请教新生,还是混充新生请教?
本来想打电话问你的,不过明天我有考试,你说你看见了就简单得作答一下子呗
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:noah (等级:8 - 融会贯通,发帖:753) 发表:2006-02-28 19:40:49  9楼
approximation algorithmThis bin-pack problem is extensively used as an example for approximation algorithms in NP-complete problems. You should be able to find the explainations and proofs (for both FF and FFD) in a reasonable college computer algorithm textbook, under NP-complete section, but it might not be covered in an undergraduate algorithm course. Briefly put, given an optimal solution of value O to an NP problem, and an approximation algorithm (in polynomial time) that outputs a solution that is k*O on average, then this approximation algorithm is called a k-approximation. If I remember correctly, FFD is an 3/2 approximation algorithm.
谢谢“这么多马甲”同学,呵呵
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:Bird (等级:5 - 略有小成,发帖:759) 发表:2006-03-03 19:10:03  10楼
本来想打电话问你的,不过明天我有考试,你说你看见了就简单得作答一下子呗
oh....
first fit is 2-approximate...to show that,
We first show that all bins (最多1个例外) at the end will be at least half full
Say each bin has capacity P
The intuition is that, at each instance in the packing process, if there's already a less-than-half full bin, the next item will either
1. settle in a new empty bin, if it's weight > P/2, or
2. settle in that less-than-half full bin
Either case, # of less-than-half full bins remains at most one....you can continue the proof...


For the second part, I dunno how to attack it...will try if i get more time
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:Bird (等级:5 - 略有小成,发帖:759) 发表:2006-03-03 19:14:31  11楼
传说中用动态规划...晕了,两年没看过了
不一样。。。
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:noah (等级:8 - 融会贯通,发帖:753) 发表:2006-03-04 01:40:03  12楼
oh....first fit is 2-approximate...to show that, We first show that all bins (最多1个例外) at the end will be at least half full Say each bin has capacity P The intuition is that, at each instance in the packing process, if there's already a less-than-half full bin, the next item will either 1. settle in a new empty bin, if it's weight > P/2, or 2. settle in that less-than-half full bin Either case, # of less-than-half full bins remains at most one....you can continue the proof... For the second part, I dunno how to attack it...will try if i get more time
呵呵,替新生谢过
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
作者:Buniverse (等级:2 - 初出茅庐,发帖:2) 发表:2006-03-08 16:42:45  13楼
呵呵,替新生谢过
我是那位2006届SM3新生
谢谢学长。以后有问题还要向你们请教了。
3/2算法如何推导的?
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
论坛导航 -> 华新鲜事 -> 求学狮城 | 返回上一页 | 本主题共有 13 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码