-1

As Knapsack has a time complexity of O(nW)

for Knapsack

  1. linear time-complexity
  2. fast no matter how large W is
  3. may need a large memory when W is large
  4. if W directly proportional to n, then time complexity becomes O(n^2)
  5. none of the above

which one or none of the above is true? I think 2, 3, 4 are correct

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065

1 Answers1

0

The O(nW)-time algorithm for the knapsack problem uses Θ(n) memory if it just produces the numeric value of the answer and Θ(nW) memory if it produces the actual answer.

Given this, here are some hints:

  1. What is the definition of linear time? Is O(nW) linear time?
  2. This depends on the definition of "fast." Your teacher/professor can fill in the details about what's meant here, since this isn't a standard term.
  3. Based on what I described above, what you do think?
  4. Try substituting W = n into O(nW). What do you get back?

Hope this helps!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065