The answer is B. given that Algorithm Q solves this problem in O(nW) time. W is an integer (constant) so Q solves this problem in O(n) time.
Option A false because if the inputs are encoded in unary then Q solves this problem in O(1) time by just multiplying the unary number by N and checks whether it's equal to W or not.
Option B is True because we just need to iterate through the loop because the input is binary every time we have only two choices either add this to the sum or not when sum reaches to w answer is yes if no thought the loop then answer is no. it runs in O(n) time also
Options C and D false because given complexity of Algorithm Q is polynomial.