Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I want to show that the problem below, also known as the Knapstack Problem, is in NP (non-deterministic polynomial time). Where should I start?

Given $n$ items numbered $1$ through $n$ so that $i^{th}$ item has weight $w_i$ and value $v_i$, determine whether it is possible to select some of these items with total weight at most $W$ and total value at least $V$.

share|improve this question
    
Knapsack is clearly in NP, since we can guess what items to take and then verify in polynomial time if this is a correct solution according to our requirements. –  user12205 Oct 12 '11 at 7:16

1 Answer 1

Loosely speaking, being in NP means it's possible to verify any proposed solution efficiently. If someone proposes a selection of items, all you have to do to verify the proposal is to add up the weights and see you get at most $W$, and add up the values and see you get at least $V$.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.