Given an integer set A, we would like to find out if there exists a proper subse
ID: 3547506 • Letter: G
Question
Given an integer set A, we would like to find out if there exists a proper subset of A whose sum is the same as the sum of A. For instance, in the following array there is such a proper subset since the sum of subset {8,-2,6,4} is equal to the overall sum of the
array, which is 16. A={8, -2, -1, 2, 4, 3, -5, 6, 7, -6} Design an algorithm that checks if such a proper subset exists and returns boolean true or false. Do the complexity analysis of your algorithm. Clearly explain each step of your analysis.
Explanation / Answer
The algorithm pseudocode will be as follows:
i) enumerate all the possible proper subsets of the given set.
ii) for each set check if the sum of the set is equal to the sum of the elements in the super set.
iii) If yes return true
iv) else continue from one till all the possible subsets are checked.
v) If no such subset exists return false.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.