Question: Implement a function which prints all subsets of an integer array without using recursion. Your implementation efficiency must be O(2^n) time where n is the
Implement a function which prints all subsets of an integer array without using recursion. Your implementation efficiency must be O(2^n) time where n is the array length. Simulate recursion as specified in our lecture, without using any recursive call directly or indirectly. Your code must be general to handle any array of integers. Use standard C++, such that the following main() works. You are not allowed to modify the main(). You are not allowed to include any files or built-in libraries, except for output. Submit your standard C++ code in the textbox below. Do not write the main() again.
int main() { int a[]={1,3,8}; int n=sizeof(a)/sizeof(a[0]); GenerateSubsets(a, n); // Prints (in any order): {} {1} {3} {8} {1,3} {1,8} {3,8} {1,3,8} // For example, the following order is also ok: {} {1} {1,3} {1,3,8} {1,8} {3} {3,8} {8} return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
