##### Asked by: Fu Muhlenberg

asked in category: General Last Updated: 16th March, 2020# What is the difference between 0 1 knapsack and fractional knapsack?

**fractional knapsack**” is the one in which we can take objects in fractions, i.e, in decimals (in floating points) whereas the “

**0**/

**1 knapsack**” is the one in which we can take objects in whole numbers (in interger value).

Click to see full answer.

Similarly, you may ask, what is the time complexity of fractional knapsack?

FractionalKnapsack has time complexity O(NlogN) where N is the number of items in S. The book suggests assuming S is a **heap**-based priority queue and then the removal has complexity Θ(logN) so the up to N removals take O(NlogN). The rest of the algorithm is O(N).

Beside above, what is greedy knapsack? The basic idea of the **greedy** approach is to calculate the ratio value/weight for each item and sort the item on basis of this ratio. Then take the item with the highest ratio and add them until we can't add the next item as a whole and at the end add the next item as much as we can.

Considering this, where knapsack problem is used?

Techopedia explains **Knapsack Problem** This is a **problem** that has been studied for more than a century and is a commonly **used** example **problem** in combinatorial optimization, where there is a need for an optimal object or finite solution where an exhaustive search is not possible.

What do you understand by 0 1 knapsack problem and fractional knapsack problem?

In the 0–1 **Knapsack problem**, **we are** not allowed to break items. **We** either take the whole item or don't take it. In **Fractional Knapsack**, **we can** break items for maximizing the total value of **knapsack**. This **problem** in which **we can** break item also called **fractional knapsack problem**.