Print All Subsets of a given set (code)

PHOTO EMBED

Wed Sep 14 2022 05:34:49 GMT+0000 (Coordinated Universal Time)

Saved by @anujnema

int S[N]
void allSubsets(int pos, int len, int[] subset) 
{
  if(pos == N) 
  { 
     print(subset)
     return
  }
  // Try the current element in the subset.
  subset[len] = S[pos]
  allSubsets(pos+1, len+1, subset)
  // Skip the current element.
  allSubsets(pos+1, len, subset)
}
content_copyCOPY

https://afteracademy.com/blog/print-all-subsets-of-a-given-set