As homework we need to find a P-verifier for the subset sum problem.
Given: natural numbers $a_1, \cdots, a_n$ and $b$
Output: YES if there is a subset $S \subseteq \{a_1,\cdots,a_n\}$ where $\sum_{a \in S} = b$. NO otherwise.
My idea:
There is a verifier $V$ with a subset C as the certificate
$V=$ on input ((S,b),C)
- Test whether the sum of the numbers in C equals b
- Check if $C \subseteq S$
- Output YES if 1 and 2 are true, output NO otherwise
As well as the time complexity if the input is unary encoded.
I am not quite sure about the time compexity.
- $O(n)$ as it only has to sum up
- not sure here
- $O(n)$
Any hints would be great.