 # how to find all subset of k length of an array?

you can use bitwise operators. can you explain it because i don,t know about bitwise operator

You can use a recursive algorithm. You can take 2 cases :
1.The element is included in the subset
or
2.The element is not included in the subset.

You can refer to this stackoverflow answer for further reference and logic

Just try and understand the logic and code on your own. The logic used is as follows:

The logic used is that the for each iteration the coder performs 2 recursive calls.

First he pushes the number into a stack(the number is a part of the subset) and is in the position say i. He then calls the function recursively to find the remaining i-1 numbers.

Then he pops the number from the answer stack (the number is not a part of the subset) and calls the function recursively again to find the remaining i elements.

Try to code with this logic.Refer to this Quora answer (though not exactly this question this is somewhat similar to this one and is in c++).

https://www.quora.com/What-is-the-recursive-solution-for-finding-all-subsets-of-a-given-array

If possible I will try to provide a C++ solution later in the day.

try it yourself first. Happy coding 