Knowee
Questions
Features
Study Tools

Let S={1,2,3,5,7,10,11}. The number of non-empty subsets of S that have the sum of all elements a multiple of 3, is _____ .

Question

Let S={1,2,3,5,7,10,11}. The number of non-empty subsets of S that have the sum of all elements a multiple of 3, is _____ .

🧐 Not the exact question you are looking for?Go ask a question

Solution

This problem can be solved by using the concept of Dynamic Programming. Here are the steps:

  1. First, we need to find the sum of all elements in the set S. The sum is 1+2+3+5+7+10+11 = 39.

  2. We need to create a 2D array dp[i][j], where i ranges from 0 to 7 (the number of elements in the set) and j ranges from 0 to 39 (the sum of all elements). The value of dp[i][j] will be the number of subsets of the first i elements that have a sum equal to j.

  3. Initialize the dp array. For i=0 (no elements), the sum is always 0, so dp[0][j] = 0 for all j. Also, there is always one subset (the empty set) that has a sum of 0, so dp[i][0] = 1 for all i.

  4. Now, fill the rest of the dp array. For each element in the set (let's call it num), and for each possible sum j from num to 39, update dp[i][j] = dp[i-1][j] + dp[i-1][j-num]. This means that the number of subsets of the first i elements that have a sum equal to j is the number of subsets of the first i-1 elements that have a sum equal to j (not including num), plus the number of subsets of the first i-1 elements that have a sum equal to j-num (including num).

  5. After filling the dp array, we need to find the number of subsets that have a sum multiple of 3. This is the sum of dp[7][j] for all j that are multiples of 3.

  6. So, the answer is dp[7][0] + dp[7][3] + dp[7][6] + ... + dp[7][39].

This is a complex problem that requires a good understanding of dynamic programming and subset sums.

This problem has been solved

Similar Questions

Given a set of non-negative integers, and a value S, determine if there is a subset of the given set with sum equal to S.

If A={1, 2, 3, 4}, then the number of the subsets of A that contain the element 2 but not 3, is?a.24b.16c.8d.4

Let A and B be two sets containing four and two elements respectively. Then the number of subsets of the set A × B, each having at least three elements is :

If A = {x : x ≤ 10 and x ∈ N}, B = {2} and C = {7} and S is a subset of A such that n(S ∩ B) = 1 and n(S ∩ C) = 0, how many such subsets are possible?

How many subsets of the set {1, 2, 3, 4} that contain 3?Select one:a.9b.3c.8d.16

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.