Of course, all these items in the knapsack are evocative and what they do is they suggest a plot.
而这些东西都能唤起士兵的回忆和感情,它们作为线索。
It's a list of the contents of the knapsack of a soldier during the Vietnam War, just a list of the contents.
故事讲述了一个越战士兵,背包里的东西,只是一系列东西而已。
And so you could construct all subsets, check that the weight is less than the weight of the knapsack, and then choose the subset with the maximum value.
因此你可以构建所有子问题,判断它的重量,是否小于背包的重量,然后选择值最大的子问题。
So how long it takes to run is related to how many items I end up being able to fit into the knapsack.
所以,运行的时间是和我能够,装进背包的物品数目有关的。
Let's now go back and instantiate these ideas for the knapsack problem we looked at last time In particular, for the 0-1 knapsack problem.
让我们回来用具体例子,来说明我们上次看过的背包问题,特别是对0-1背包问题来说。
with the continuous knapsack problem as we've formulated it, greedy is good.
因为正如我们已经归越过的,对于一般连续性背包问题贪婪算法很实用。
So let's look at an example of a zero-one knapsack problem.
我们要像之前一样将其最优化,现在让我们来看一个0/1背包问题的例子。
STUDENT: You can't exceed the volume that the knapsack can hold.
学生:你不能超过背包,所能容纳物品的体积。
Typically up till now, we've looked at things that can be done in sublinear time. Or, at worst, polynomial time. We'll now look at a problem that does not fall into that. And we'll start with what's called the continuous knapsack problem.
至今为止我们已经处理过,亚线性问题,最多也就是多项式问题,我们现在要看的问题则是不能用这些解决的,我们将要开始讲连续背包问题。
应用推荐