Exams › GATE › Technical
The subset-sum problem is defined as follows: Given a set S of n positive integers and a positive integer W, determine whether there is a subset of S whose elements sum to W. An algorithm Q solves this problem in O(nW) time. Which of the following statements is false?
- Q solves the subset-sum problem in polynomial time when the input is encoded in unary
- Q solves the subset-sum problem in polynomial time when the input is encoded in binary
- The subset sum problem belongs to the class NP
- The subset sum problem is NP-hard
Correct answer: Q solves the subset-sum problem in polynomial time when the input is encoded in binary
Solution
The algorithm Q runs in O(nW) time, which is polynomial in terms of the input size when W is encoded in unary. However, when W is encoded in binary, the size of W can grow exponentially relative to its value, making the algorithm's time complexity exponential in practice, thus not polynomial.
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →