What is the sum of each of the balanced partitions for the array {5, 6, 7, 10, 3, 1}?
16
32
0
64
Answer and explanation
The sum of all the elements of the array is 32. So, the sum of all the elements of each partition should be 16.
ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
6 practice sets · Page 1 of 1
What is the sum of each of the balanced partitions for the array {5, 6, 7, 10, 3, 1}?
16
32
0
64
The sum of all the elements of the array is 32. So, the sum of all the elements of each partition should be 16.
Which of the following lines should be inserted to complete the above code?
ans[i - arr[j - 1]][j - 1]
ans[i][j]
ans[i][j] || ans[i - arr[j - 1]][j - 1]
ans[i][j] && ans[i - arr[j - 1]][j - 1]
The line "ans[i][j] || ans[i - arr[j - 1]][j - 1]" completes the above code.
Consider a variation of the balanced partition problem in which we find two subsets such that |S1 - S2| is minimum. Consider the array {1, 2, 3, 4, 5}. Which of the following pairs of subsets is an optimal solution for the above problem?
{5, 4} & {3, 2, 1}
{5} & {4, 3, 2, 1}
{4, 2} & {5, 3, 1}
{5, 3} & {4, 2, 1}
For S1 = {5, 3} and S2 = {4, 2, 1}, sum(S1) - sum(S2) = 1, which is the optimal solution.
What is the time complexity of the brute force algorithm used to solve the balanced partition problem?
O(1)
O(n)
O(n^{2})
O(2^{n})
In the brute force implementation, all the possible subsets will be formed. This takes exponential time.
In which of the following cases, it is not possible to have two subsets with equal sum?
When the number of elements is odd
When the number of elements is even
When the sum of elements is odd
When the sum of elements is even
When the sum of all the elements is odd, it is not possible to have two subsets with equal sum.
Given an array, check if the array can be divided into two subsets such that the sum of elements of the two subsets is equal. This is the balanced partition problem. Which of the following methods can be used to solve the balanced partition problem?
Dynamic programming
Recursion
Brute force
Dynamic programming, Recursion, Brute force
All of the mentioned methods can be used to solve the balanced partition problem.