Are O(n*2^n) and O(2^n) same? Whats the complexity of this program?
Hi, i wrote this program for generating powerset of a list, using recursion in python. https://code.sololearn.com/cPM3De7f0Tjn I cant figure out whats the complexity of this program? I see that there are n recursion steps to break list into 1 element, that seem like a linear function to me. Now at each recursion steps i am iterating over generated subsets, which increase by factor of 2^n at each step. in final steps the factor is almost equal to 2^n so i assume that complexity is 2^n, and that is nested under n recursion steps, so that should be n*2^n? Or it should be just written as 2^n? If yes, then why do we not ignore n or log(n) in n*log(n). Also if i use this function in another function where I loop n times and at each loop i generate power set of same list of n elements, what would be the complexity of that? Thank you for taking time to help me :)