Loading practice questions
What is the time complexity of the brute force algorithm used to solve the Knapsack problem?
Correct Answer: C — O(2^{n})
Explanation:
In the brute force algorithm all the subsets of the items are found and the value of each subset is calculated. The subset of items with the maximum value and a weight less than equal to the maximum allowed weight gives the answer. The time taken to calculate all the subsets is O(2^{n}).