Çë½ÌÒ»¸öËã·¨µÄÎÊÌâÒ»¸öjuniorÎÊÎÒÒ»¸öËã·¨µÄÎÊÌ⣬¿ÉÊÇÎÒµÄËã·¨ÊÇÓÃÓ¢ÎÄѧµÄ£¬¿´²»¶®ËûµÄÌâ¸É¡£ÄÄÎ»Ôø¾ÓÃÖÐÎÄѧ¹ýËã·¨µÄÅóÓѰï¸öæ°É¡£Ð»Ð»~~
Ç뿼ÂÇ×°ÏäÎÊÌâµÄ̰À·Ëã·¨£¬ËûÒ²±»³ÆÎªÓÅÏÈÈÝÄÉËã·¨£¨first-fit,FF£©£º°´ÕÕÿ¸öÎï
Æ·¸ø³öµÄ˳Ðò£¬°ÑËü×°ÈëµÚÒ»¸öÄܹ»ÈÝÄÉËüµÄÏä×Ó£»Èç¹ûÕâÑùµÄÏä×Ó²»´æÔÚ£¬¾Í°Ñ¸ÃÎï
Æ··ÅÔÚÒ»¸öÐÂÏä×ÓÀ²¢½«¸ÃÏä×Ó·¿×ÓÏä×ÓÁбíµÄβ²¿¡£
1£©Ö¤Ã÷FFËã·¨ÊÇÒ»¸ö2½üËÆµÄËã·¨
×°ÏäÎÊÌ⻹ÓÐÒ»¸ö½µÐòÓÅÏÈÈÝÄÉËã·¨£¨first-fit decreasing,FFD£©£ºËüÔÚ¿ªÊ¼µÄʱºò
£¬¶ÔÎïÆ·°´ÕÕÌå»ýµÄ½µÐò½øÐÐÅÅÐò£¬È»ºóÔÙÖ´ÐÐÓÐÏÞÈÝÄÉËã·¨¡£
2£©ÕâÊǸö¼¸½üËÆËã·¨£¿Ö¤Ã÷Ö®¡£
ÌâÄ¿À´Ô´£º
£¨ÃÀ£©Anany Levitin
Introdution to The Design and Analysis of Algorithms [noah (2-27 19:01, Long long ago)]
[ ´«Í³°æ |
sForum ][µÇ¼ºó»Ø¸´]1Â¥
ÏÈÎÊÒ»¸öÎÊÌ⣺Õâ¸öÊDz»ÊÇÀàËÆÓÚÎÒÃdz£¼ûµÄ±³°üÎÊÌâ¡£
¾ÍÊÇ˵£¬Ð¡ÍµÍµ¶«Î÷£¬·¢ÏÖÓÐN¼þ£¬µÚI¼þ¼ÛÖµViÔª£¬ÖØWiǧ¿Ë¡£¶¼ÊÇÖ¤Êé¡£ÄÇôËûÏ£Íû´ø×ßԽֵǮµÄ¶«Î÷¡£µ«ÊDZ³°üÀïÃæÖ»ÄÜÈÝÄÉWǧ¿Ë¡£
Ôõô°ìÄØ£¿
ÊDz»ÊÇÕâÖÖÎÊÌ⣿ÒòΪÎÒÓ¡ÏóÎÒÃǵ±Ê±ÓÃ̰ÐÄËã·¨¡£[ÞÈѾ (2-27 21:32, Long long ago)]
[ ´«Í³°æ |
sForum ][µÇ¼ºó»Ø¸´]2Â¥
×°ÏäÎÊÌâ ? ÓÐÒ»¸öÏä×ÓÈÝÁ¿Îªv(ÕýÕûÊý£¬o¡Üv¡Ü20000)£¬Í¬Ê±ÓÐn¸öÎïÆ·(o¡Ün¡Ü30)£¬Ã¿¸öÎïÆ·ÓÐÒ»¸öÌå»ý (ÕýÕûÊý)¡£ÒªÇó´Ó n ¸öÎïÆ·ÖУ¬ÈÎÈ¡Èôǧ¸ö×°ÈëÏäÄÚ£¬Ê¹Ïä×ÓµÄÊ£Óà¿Õ¼äΪ×îС¡£
[ÑùÀý]
ÊäÈ룺
24 Ò»¸öÕûÊý£¬±íʾÏä×ÓÈÝÁ¿
6 Ò»¸öÕûÊý£¬±íʾÓÐn¸öÎïÆ·
8 ½ÓÏÂÀ´nÐУ¬·Ö±ð±íʾÕân¸öÎïÆ·µÄ¸÷×ÔÌå»ý¡£
3
12
7
9
7
Êä³ö£º
0 Ò»¸öÕûÊý£¬±íʾÏä×ÓÊ£Óà¿Õ¼ä¡£[ÞÈѾ (2-27 21:40, Long long ago)]
[ ´«Í³°æ |
sForum ][µÇ¼ºó»Ø¸´]3Â¥
(ÒýÓà ÞÈѾ:×°ÏäÎÊÌâ ? ÓÐÒ»¸öÏä×ÓÈÝÁ¿Îªv(ÕýÕûÊý£¬o¡Üv¡Ü20000)£¬Í¬Ê±ÓÐn¸öÎïÆ·(o¡Ün¡Ü30)£¬Ã¿¸öÎïÆ·ÓÐÒ»¸öÌå»ý (ÕýÕûÊý)¡£ÒªÇó´Ó n ¸öÎïÆ·ÖУ¬È...)´«ËµÖÐÓö¯Ì¬¹æ»®...ÔÎÁË£¬Á½Äêû¿´¹ýÁË[ÞÈѾ (2-27 21:41, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]4Â¥
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.[Âí¼×¼×¼× (2-27 23:18, Long long ago)]
[ ´«Í³°æ |
sForum ][µÇ¼ºó»Ø¸´]5Â¥
ÄãÊÇÇë½ÌÐÂÉú£¬»¹ÊÇ»ì³äÐÂÉúÇë½Ì£¿[Bird (2-28 0:04, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]6Â¥
(ÒýÓà Bird:ÄãÊÇÇë½ÌÐÂÉú£¬»¹ÊÇ»ì³äÐÂÉúÇë½Ì£¿)ÎÒ°ïÐÂÉúÇë½Ì[noah (2-28 0:21, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]7Â¥
(ÒýÓà Bird:ÄãÊÇÇë½ÌÐÂÉú£¬»¹ÊÇ»ì³äÐÂÉúÇë½Ì£¿)±¾À´Ïë´òµç»°ÎÊÄãµÄ£¬²»¹ýÃ÷ÌìÎÒÓп¼ÊÔ£¬Äã˵Äã¿´¼ûÁ˾ͼòµ¥µÃ×÷´ðÒ»ÏÂ×ÓßÂ[noah (2-28 0:25, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]8Â¥
(ÒýÓà Âí¼×¼×¼×:approximation algorithmThis bin-pack problem is extensively used as an example for approximation algorithms in NP-complete probl...)лл¡°Õâô¶àÂí¼×¡±Í¬Ñ§£¬ºÇºÇ[noah (2-28 19:40, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]9Â¥
(ÒýÓà noah:±¾À´Ïë´òµç»°ÎÊÄãµÄ£¬²»¹ýÃ÷ÌìÎÒÓп¼ÊÔ£¬Äã˵Äã¿´¼ûÁ˾ͼòµ¥µÃ×÷´ðÒ»ÏÂ×ÓßÂ)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[Bird (3-3 19:10, Long long ago)]
[ ´«Í³°æ |
sForum ][µÇ¼ºó»Ø¸´]10Â¥
(ÒýÓà ÞÈѾ:´«ËµÖÐÓö¯Ì¬¹æ»®...ÔÎÁË£¬Á½Äêû¿´¹ýÁË)²»Ò»Ñù¡£¡£¡£[Bird (3-3 19:14, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]11Â¥
(ÒýÓà Bird: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...)ºÇºÇ£¬ÌæÐÂÉúл¹ý[noah (3-4 1:40, Long long ago)] [ ´«Í³°æ | sForum ][µÇ¼ºó»Ø¸´]12Â¥
(ÒýÓà noah:ºÇºÇ£¬ÌæÐÂÉúл¹ý)ÎÒÊÇÄÇλ2006½ìSM3ÐÂÉúллѧ³¤¡£ÒÔºóÓÐÎÊÌ⻹ҪÏòÄãÃÇÇë½ÌÁË¡£
3/2Ëã·¨ÈçºÎÍÆµ¼µÄ£¿[Buniverse (3-8 16:42, Long long ago)]
[ ´«Í³°æ |
sForum ][µÇ¼ºó»Ø¸´]13Â¥