0
0
DSA Typescriptprogramming~5 mins

Fractional Knapsack Problem in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main goal of the Fractional Knapsack Problem?
To maximize the total value of items placed in a knapsack with a fixed capacity, allowing fractions of items to be taken.
Click to reveal answer
beginner
Why can we take fractions of items in the Fractional Knapsack Problem but not in the 0/1 Knapsack Problem?
Because the problem assumes items are divisible, like liquids or materials, allowing partial amounts to be taken, unlike 0/1 Knapsack where items are indivisible.
Click to reveal answer
intermediate
What is the greedy strategy used in the Fractional Knapsack Problem?
Sort items by their value-to-weight ratio in descending order and take as much as possible from the highest ratio items first.
Click to reveal answer
intermediate
In the Fractional Knapsack Problem, what happens if the knapsack capacity is less than the weight of the current item?
We take only the fraction of the item that fits into the remaining capacity to maximize value.
Click to reveal answer
intermediate
What is the time complexity of the Fractional Knapsack Problem when using sorting?
O(n log n) due to sorting the items by value-to-weight ratio, where n is the number of items.
Click to reveal answer
What is the key difference between Fractional Knapsack and 0/1 Knapsack?
ABoth allow fractions of items
B0/1 Knapsack allows fractions, Fractional Knapsack does not
CNeither allows fractions of items
DFractional Knapsack allows taking parts of items, 0/1 Knapsack does not
Which greedy criterion is used to select items in Fractional Knapsack?
AHighest value-to-weight ratio first
BLowest value first
CHighest weight first
DRandom selection
If the knapsack capacity is 50 and the next item weighs 70, what fraction of the item is taken?
A0.5
B1
C0.714
D0.7
What is the first step in solving the Fractional Knapsack Problem?
ASort items by value-to-weight ratio descending
BSort items by value descending
CSort items by weight ascending
DPick items randomly
What is the overall time complexity of the Fractional Knapsack algorithm?
AO(n)
BO(n log n)
CO(n^2)
DO(log n)
Explain the greedy approach used in the Fractional Knapsack Problem and why it works.
Think about choosing the most valuable parts first to fill the knapsack.
You got /5 concepts.
    Describe how to handle an item that cannot fit fully into the remaining knapsack capacity in the Fractional Knapsack Problem.
    Partial items are allowed, so take only what fits.
    You got /4 concepts.