I would like to know if there is an efficient algorithm to generate all the combinations of 0's and 1's with length n given the minimum and maximum amount of 1's.
Example:
n=4 min=2 max=3
0011 0101 1001 0110 1010 1100 (with 2 1's)
0111 1011 1101 1110 (with 3 1's)
I know I could count in binary from (n-min)*0(min)*1 up to (max)*1 (n-max)*0 (0011 up to 1110 for the example) and take all those that satisfy the constraints, but I would like to know if there is an algo that is more efficient.