用贪婪算法解决背包问题
Introduction:
介绍:
Let's start the discussion with an example that will help to understand the greedy technique. If we think about playing chess, when we make a move we think about the consequences of the move in future states, but in case of playing cricket or tennis, we consider immediate states rather considering any future consequences. This means in some cases we make decisions which seems to be correct at that moment and in some cases we make a decision based on the following consequences or future cases.
让我们从一个有助于理解贪婪技巧的例子开始讨论。 如果我们考虑下棋,那么当我们做出举动时,我们会考虑这一举动在未来状态下的后果,但是在打板球或打网球的情况下,我们考虑的是即时状态,而不是考虑任何未来的后果 。 这意味着在某些情况下,我们做出当时似乎正确的决定,并且在某些情况下,我们基于以下后果或未来情况做出决定。
The idea of local and global can take place here. Local means the immediate case where global means considering the future situation.
本地和全球的想法可以在这里进行。 本地意味着眼前的情况,而全球意味着考虑未来的情况。
The greedy technique is all about making a local decision, based n that immediate case, on based on future consequences and that's why the strategy is known as greedy.
贪婪的技巧全在于根据紧急情况基于未来的后果做出本地决策,这就是为什么该策略被称为贪婪的原因 。
贪婪策略 (Greedy strategy)
Greedy strategy means to make a decision at e