Subset Sum—Dynamic Programming
Discover the different techniques used to solve the subset sum problem efficiently.
We'll cover the following...
Dynamic programming algorithm for subset sum problem
Recall that the subset sum problem asks whether any subset of a given array of positive integers sums to a given integer . In a previous lesson, we developed a recursive subset sum algorithm that can be reformulated as follows. Fix the original input array and define the boolean function if and only if some subset of sums to
We need to compute . This function satisfies the following recurrence:
...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy