• retagged by
660 views

1 Answer

0 0 votes
Depending on the implementation it can be O(nw) or O(2^n)

 To compute in O(2^n) is simple to implement: suppose there are n items in 0/1 knapsack you have 2 option for each item,either select it or reject it,so it becomes o(2^n).
Position:
Show:

Related questions

1 1 vote
1 1 answer
1.1k
1.1k views
gatecse asked Dec 9, 2020
1,107 views
Which of the following is a correct time complexity to solve the $0/1$ knapsack problem where $n$ and $w$ represents the number of items and capacity of knapsack respecti...
0 0 votes
1 1 answer
1.4k
1.4k views
Rohit Pandey asked Jun 27, 2018
1,421 views
What will be the time complexity if fractional knapsack is implemented using min heap instead of sorted arraya) O(nlogn)b)O(n^2)c)O(n)d) none of these
0 0 votes
1 1 answer
477
477 views
Shubham Sharma 2 asked Sep 9, 2025
477 views
Arrange the following steps in the correct order to solve the Knapsack problem using Dynamic Programming.Define the base case when the capacity is zero ($0$) or no items ...