Coders Packet

Print all Subsets of a given Array Using Recursion in C++


This Project Prints all the Subsets of the Array.Input will be given by User i.e.., an Array and Size of Array 'N' using C++ programming language.

This Project print all the subsets of the given array using the recursion concept. 

Given an integer array of elements and the size of the array By the User. 

Have to print all the Subsets of the array. 

Example :

Input: a = [1,2,3],N=3
Output: [[1],[1,2],[1,2,3],[1,3],[2],[2,3],[3]]  

Approach :
First We Create a recursive function by passing paramaters as given array
we will traverse through out the array using recursion concept we will generate all subsets
and push back them into a 2D vector which will be the answer.

Note : We are printing the subsets using recursion concept the time complexity will be,

Time Complexity :O( 2^n *(log (x) ))

Auxilary Space :O(N)

Download Complete Code


No comments yet