计算机工程与应用 ›› 2012, Vol. 48 ›› Issue (4): 50-53.

• 研究、探讨 • 上一篇    下一篇

求解0-1背包问题的一种新混合算法

孙怀影1,耿寅融1,单 谦2   

  1. 1.暨南大学 信息科学技术学院 计算机科学系,广州 510632
    2.暨南大学 产业经济研究院 产业经济学系,广州 510632
  • 收稿日期:1900-01-01 修回日期:1900-01-01 出版日期:2012-02-01 发布日期:2012-04-05

New hybrid algorithm to solve 0-1 knapsack problem

SUN Huaiying1, GENG Yinrong1, SHAN Qian2   

  1. 1.Department of Computer Science, College of Information Science and Technology, Jinan University, Guangzhou 510632, China
    2.Department of Industrial Economics, Institute of Industrial Economics, Jinan University, Guangzhou 510632, China
  • Received:1900-01-01 Revised:1900-01-01 Online:2012-02-01 Published:2012-04-05

摘要: 用动态规划算法求解0-1背包问题的时空复杂度为O(nC)。这个空间复杂度在求解大规模问题上是不可接受的。从计算0-1背包问题最优值的递归方程出发,给出高效利用内存的动态规划算法。为了克服内存高效的动态规划算法带来的缺点,设计新混合算法求解0-1背包问题。该新混合算法的时间复杂度为O(nC);它消除了回溯阶段,并且为求得放入背包的物品所使用的空间复杂度仅为O(「n/d?+C),其中d为计算机字长。实验结果表明,混合算法的工作效率与理论分析相同。

关键词: 0-1背包问题, 动态规划, 分治策略, 混合算法

Abstract: When using dynamic programming algorithm to solve 0-1 knapsack problem, its time complexity and space complexity both are O(nC). Its space complexity is not acceptable in case of large scale problem. From the recursive equations for computing optimal value of 0-1 knapsack problem, Memory Efficient Dynamic Programming(MEDP) is proposed. In order to conquer the drawback of MEDP, a new hybrid algorithm is put forward, which combines divided-and-conquered strategy with it and whose time complexity is O(nC). The hybrid algorithm eliminates the backtracking step, while it can find the goods put into the knapsack under the space complexity O(「n/d? + C), where d is the word length of computer. Experimental result demonstrates that the algorithm works identically with the theory.

Key words: 0-1 knapsack problem, dynamic programming, divided-and-conquered, hybrid algorithm