Khan.randRange( 6, 10 ) initJSAV(A) genAnswer()
Is the current item taken or left behind?
genAnswer()
  • "Take It"
  • "Leave It"

Look at positions (0, table[1].size()) and (0, table[1].size()-1-item.value(0)).

If the item is left behind, move strait up the table and gain no extra value.

If the item is taken you have reduced capacity in the knapsack but gain the value of the item. Move left by the items weight and up one to the next item

Remember, if the value is a tie, it does not matter if the item is left or taken. In the event of a tie, leave the item behind by default.