1.

The main time taking step in fractional knapsack problem is ___________(a) Breaking items into fraction(b) Adding items into knapsack(c) Sorting(d) Looping through sorted itemsThis question was posed to me in homework.My question comes from Greedy Algorithms topic in division Greedy Algorithms of Data Structures & Algorithms II

Answer»

The CORRECT option is (c) Sorting

Explanation: The main time TAKING STEP is to sort the ITEMS according to their value/weight ratio. It DEFINES the time complexity of the code.



Discussion

No Comment Found

Related InterviewSolutions