Questions tagged «powerset»


26
在Java中获取集合的幂集
的幂集{1, 2, 3}是: {{}, {2}, {3}, {2, 3}, {1, 2}, {1, 3}, {1, 2, 3}, {1}} 假设我有一个SetJava语言: Set<Integer> mySet = new HashSet<Integer>(); mySet.add(1); mySet.add(2); mySet.add(3); Set<Set<Integer>> powerSet = getPowerset(mySet); 如何编写具有最佳可能复杂度的函数getPowerset?(我认为可能是O(2 ^ n)。)
86 java  algorithm  set  powerset 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.