I am cluelessly trying to solve this problem:
Let
arr
be an array of integers of lengthn
(indexed from 1 to n).Let
M[s][i]
be a matrix containing boolean values of, if there exist a subset of firsti
numbers of the array arr (arr[1], arr[2], ..., arr[i], ..., arr[n]), of which the sum is exactlys
.Find the recursive formula for the value of
M[s][i]
based onM[?][j]
, where j < i andarr
containsj
. You can assume thatM[s][0] = 0
.
How would I find this formula? I would be grateful for any help.