如果我有一组未排序的大n
整数(比如2^20
它们),并且想生成k
每个元素的子集(k
比如小5
),它们的总和顺序是递增的,那么最有效的方法是什么?
为什么我需要以这种方式生成这些子集是因为我想找到满足某个条件的最小和的 k 元素子集,因此我会将条件应用于生成的每个 k 元素子集。
另外,算法的复杂度是多少?
这里有一个类似的问题:Algorithm to get every possible subset of a list, in order to their product, without building and sort the entire list (ie Generators) about generate subsets of their product,但它不适合我由于集合的尺寸非常大,因此需要n
我打算在 Mathematica 中实现该算法,但也可以在 C++ 或 Python 中实现。