Fractional knapsack problem is solved most efficiently by which of the…
2024
Fractional knapsack problem is solved most efficiently by which of the following algorithm?
- A.
Backtracking
- B.
Greedy algorithm
- C.
Dynamic programming
- D.
More than one of the above
- E.
None of the above
Attempted by 544 students.
Show answer & explanation
Correct answer: B
Solution
The Fractional Knapsack Problem is best solved using the Greedy Algorithm.
In this problem, we can take fractions of items. The optimal strategy is to calculate the value-to-weight ratio for each item and sort them in descending order. We then pick items starting from the highest ratio until the knapsack is full. If an item cannot fit entirely, we take the fraction that fills the remaining capacity.
हिन्दी उत्तर
फ्रैक्शनल नैपसैक समस्या को हल करने के लिए ग्रीडी एल्गोरिद्म (Greedy Algorithm) सबसे प्रभावी है।
इस समस्या में हम वस्तुओं के अंश (fraction) ले सकते हैं। सर्वोत्तम रणनीति यह है कि प्रत्येक वस्तु के लिए मूल्य-से-वजन अनुपात (value-to-weight ratio) की गणना करें और उन्हें अवरोही क्रम में व्यवस्थित करें। फिर हम सबसे उच्च अनुपात वाली वस्तुओं को चुनते हैं जब तक कि नैपसैक भर नहीं जाता। यदि कोई वस्तु पूरी तरह फिट नहीं होती, तो हम शेष क्षमता भरने के लिए उसका अंश लेते हैं।