1.

Fractional knapsack problem is solved most efficiently by which of the following algorithm?(a) Divide and conquer(b) Dynamic programming(c) Greedy algorithm(d) BacktrackingI have been asked this question in semester exam.My doubt is from Greedy Algorithms topic in division Greedy Algorithms of Data Structures & Algorithms II

Answer»

The CORRECT answer is (C) Greedy algorithm

Easy EXPLANATION - Greedy algorithm is used to solve this problem. We first sort items ACCORDING to their value/weight ratio and then add item with highest ratio until we cannot add the next item as a whole. At the end, we add the next item as much as we can.



Discussion

No Comment Found

Related InterviewSolutions