关于背包的问题?
questions about knapsack?
美好的一天,
背包算法并不完全"click"在我的脑海中。我知道如何很好地回答不同变体的背包问题(0-1 背包,携带香料的背包等),但我并不完全理解算法本身;我很乐意填补空白
为了让我的问题不那么含糊,我将我的问题分解为几个子问题。另外这是我在考试中对背包问题的典型答案,
Construct X-dimensional matrix (where X is a number of variables to keep an eye on). From point 0 {0,0,...0}, calculate neighbouring nodes, and then from the results obtained, will the next diagonal point in the matrix with the result giving by far the most optimal solution. Repeat until all considered options in the algorithm are exahusted
我们怎么知道背包算法有效(除了经验观察)?特别是,我们如何确切地知道没有考虑 s.t 的可选配置。它最终产生了比我们的算法 returns 更优化的结果?
使用"X-dimensional matrix"似乎在内存使用方面非常冗余,背包问题是否有更优化的数据结构?也许是最小-最大二叉树(对于这种情况 "seems" 更优化)
假设我们有一个非常大的背包。用贪婪的方法(物品给出最佳比例)填满背包,直到只剩下很少的space,这样不是更有效吗?在我看来,到这里还剩下 space 的 2*(largest item)
?
干杯
1) 由于背包算法是一个贪心算法,我们知道该算法有贪心选择属性(也为某个最优解做出选择)并且它有最优子结构。因此,不可能有更好的结果,因为我们的算法总是选择最佳决策。
美好的一天,
背包算法并不完全"click"在我的脑海中。我知道如何很好地回答不同变体的背包问题(0-1 背包,携带香料的背包等),但我并不完全理解算法本身;我很乐意填补空白
为了让我的问题不那么含糊,我将我的问题分解为几个子问题。另外这是我在考试中对背包问题的典型答案,
Construct X-dimensional matrix (where X is a number of variables to keep an eye on). From point 0 {0,0,...0}, calculate neighbouring nodes, and then from the results obtained, will the next diagonal point in the matrix with the result giving by far the most optimal solution. Repeat until all considered options in the algorithm are exahusted
我们怎么知道背包算法有效(除了经验观察)?特别是,我们如何确切地知道没有考虑 s.t 的可选配置。它最终产生了比我们的算法 returns 更优化的结果?
使用"X-dimensional matrix"似乎在内存使用方面非常冗余,背包问题是否有更优化的数据结构?也许是最小-最大二叉树(对于这种情况 "seems" 更优化)
假设我们有一个非常大的背包。用贪婪的方法(物品给出最佳比例)填满背包,直到只剩下很少的space,这样不是更有效吗?在我看来,到这里还剩下 space 的
2*(largest item)
?
干杯
1) 由于背包算法是一个贪心算法,我们知道该算法有贪心选择属性(也为某个最优解做出选择)并且它有最优子结构。因此,不可能有更好的结果,因为我们的算法总是选择最佳决策。