4 ms·
Also useful to generate subsets since possible the number of subsets of a set of n elements is 2^n. for (int i = 0; i << n; i++) { ... } (won't wo
by partycoder 8y ago
Also useful to generate subsets since possible the number of subsets of a set of n elements is 2^n.
for (int i = 0; i << n; i++) {
...
}
(won't work for a large n)
Also... dividing by 2 is (n >> 1) and multiplying by 2 is (n << 1).
- enthdegree 8y agolooping in order of subset size can be done easily too: https://en.wikipedia.org/wiki/Combinatorial_number_system#Applications https://en.wikipedia.org/wiki/Combinatorial_number_system#Ap...