Analysis
- Two methods applied both of which are pretty straightforward
- (1) Sort the original array and extract a new array without duplicates but count the number of each element. Then use DFS all possible subset and in each search step, iterate to insert the current element from 0 times to the number of that element times.
- (2) Sort the original array and extract a new array without duplicates but count the number of each element. Generate the possible subsets iteratively. At each step, copy all of the previous generated results and insert the current element at the end of each results
- Seems that iterative way should faster then recursive way however the running results are opposite.
Note
Code
Iteration
No comments:
Post a Comment
Enter you comment