What is total possible no of subsets of a set with given n elements and max subset length possible is k

247 Views Asked by At

For Example let's say the given set is $\{1, 2, 3, 4\}$ i.e $n=4$ elements and I have to find the subsets possible till the maximum length of $k=2$.

To do this i've to do All possible combinations of subsets from length $0$ to length $k =2$ which causes time limit exceeded to my problem .

Since the calculation of total no of subsets i.e till the maximum length of set possible is much easier to find using $2^n$ which takes only $\log n$ time asymptotically

So my Question is.. Can we find this for $k$ in $\log(n)$ time which would be something like $2^n$ or in exponential form ?