Category Archives: Greedy

Fractional Knapsack Problem

Given weights and values of n items, we need put these items in a knapsack of capacity W to get the maximum total value in the knapsack. In the 0-1 Knapsack problem, we are not allowed to break items. We either take the whole item or don’t take it. Input: Items as (value, weight) pairs… Read More »

Bin Packing Problem (Minimize number of used Bins)

Given n items of different weights and bins each of capacity c, assign each item to a bin such that number of total used bins is minimized. It may be assumed that all items have weights smaller than bin capacity.

Shortest Superstring Problem

Given a set of n strings arr[], find the smallest string that contains each string in the given set as substring. We may assume that no string in arr[] is substring of another string.