educative.io

Why are we excluding the element and then including the element to get the profits?

Hi,

I am new to Dynamic programming. I am just wondering if there is an advantage of chosing to exclude and include elements and take their profits separately and then returning the maximum from the retrieved profits.
Please let me know.

Thanks.

1 Like

Hi Gautham,

Thanks for reaching out.

The main idea behind inclusion or exclusion of items is that since we don’t know if we get the maximum profit after including an item or skipping it, therefore, we have to try all combinations of the items and then see which combination gives us the maximum profit. Another way of saying this is, when we exclude an item then we allow another item to be included in the knapsack, which might gives us more profit than including the first item.

Hope this answers your question.

1 Like

Thanks,

That makes sense. By the way, Great course material. Loving the course so far!

2 Likes