DP:背包问题 Knapsack Problem

本文介绍了背包问题,特别是01背包和完全背包问题,作为动态规划初学者的良好实例。动态规划通过最优子结构和重叠子问题解决最优化问题。01背包问题中,优化策略可将空间优化至O(M),完全背包则需正向遍历以获取当前层最优解。
摘要由CSDN通过智能技术生成

    背包问题非常适合动态规划的初学者。

    Knapsack problem is very suitable for dynamic programming(DP) beginners.

    首先我们适当讨论下动态规划。采用动态规划方法解决最优化问题的两个基本要素,是最优子结构和重叠子问题。

    First of all, let's talk something about DP. The optimal substructure and overlapping sub-problems are the two basic elements to solve the optimization problem by DP method.

    如果一个问题最优解包含了子问题的最优解,称其具有最优子结构。DP以自底向上的方法利用最优子结构,即先找子问题最优解,再找当前问题最优解。问题解代价为子问题代价与转移代价。DP与贪心的区别在于,DP根据子问题最优解进行转移,而贪心直接转移,属于自顶向下的方式。另外,子问题间要相互独立,即所谓的“无后效性”,否则无法计算子问题,也谈不上求解当前问题。

    If a question's optimal solution needs its sub-optimal solutions, we call it has an optimal substructure. DP utilizes it by bottom-up method, which means finding sub-problems' optimal solutions firstly, then itself.  The cost is the sum of sub-problems' cost and transferring. The difference between DP and greedy is, the former one transfers on the

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值