Give a pseudopolynomial algorithm for Knapsack. Strive for running time of O(nB), but make sure running time is polynomial in n and B. The Knapsack problem is defined as follows. An instance consists of n items 1, 2, . . . , n where item i has size si and profit pi , and a knapsack size B with B = si for all i = 1, 2, . . . , n. All the numbers are integers. A feasible solution consists of a subset Q of {1, 2, . . . , n} such that P i?Q si = B. The objective is to maximize the total profit of Q – that is P i?Q pi . Present the pseudocode, discuss correctness, and analyze the running time.
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp