1.

Time complexity of fractional knapsack problem is ____________(a) O(n log n)(b) O(n)(c) O(n^2)(d) O(nW)This question was posed to me in semester exam.I need to ask this question from Greedy Algorithms in section Greedy Algorithms of Data Structures & Algorithms II

Answer»

Correct answer is (a) O(n log n)

The best I can explain: As the main TIME taking a step is of sorting so it DEFINES the time complexity of our code. So the time complexity will be O(n log n) if we USE QUICK sort for sorting.



Discussion

No Comment Found

Related InterviewSolutions