Computer Science EngineeringVery hard
The 0/1 knapsack problem with n items and capacity W is solved by dynamic programming in time
- A. O(n + W)
- B. O(W^n)
- C. O(nW)
- D. O(n log W)
Correct answer: C. O(nW)
The table has n*W entries each computed in constant time, which is pseudo-polynomial.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- A red-black tree with n internal nodes has height at most
- The Floyd-Warshall all-pairs shortest path algorithm runs in time
- What does f(4795) return for int f(int n){ return n==0 ? 0 : n%10 + f(n/10); }
- A union-find structure with union by rank and path compression supports each operation in amortized time
- The number of inversions in the array [3, 1, 2, 5, 4] is
- A full binary tree (every node has 0 or 2 children) has 20 leaves. How many internal nodes does it have?