📑 Task
1) This program divides a set into two subsets sothat the difference in the sums of the subsets is minimal
The variable "table" indicates whether it is possible
to achieve a sum of j using the first i elements
Will all values be equal to 1 in the last row of the printed table?
2) During the iteration process, we actually only use the last two rows of the table
Can you modify the program using this fact?
📑 Answer
1) The last line will be [1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]We will not be able to get sums equal to 2 and 5
from the numbers presented in the original list
2)
No comments:
Post a Comment