for n=5, W=100000 Here w has larger value.
Here n is polynomial in length but length of w not polynomial it can anything.
When comparing this with the brute force algo take O(2n), but depending on W, either the dynamic programming algorithm is more efficient or the brute force algorithm could be more efficient. (For example, for n=5, W=100000, brute force is preferable, but for n=30 and W=1000, the dynamic programming solution is preferable.)