You are on page 1of 5

Knapsack Problem

Insights:
• Knapsack Problem – An Introduction
• Knapsack Problem – Variants & Its difference.
• Knapsack Problem
• Example:
• Solution 1 – Random Selection
• Solution 2 - Decreasing order of Profits
• Solution 3 – Increasing order of Weights
• Solution 4 – Decreasing order of Profit per Weight
• Greedy Algorithm for Knapsack Problem
• Algorithm
• Time Com/plexity

Knapsack Problem – An Introduction


Knapsack Problem:
}
Time Complexity
• The main time taking step is the sorting of all items in the decreasing order of their value / weight ratios.
• If the items are already arranged in the required order, the while loop takes O(n) time.
• Quick sort’s average time complexity is O(nlogn), therefore total time taken including the sort is
O(nlogn)

You might also like