Relative Content

Tag Archive for algorithmsubsequence

Time Complexity of the Iterative Version of the Subsequence Question

What will be the time complexity of the Code below, as my teacher said the time complexity will be O(N2^N).
My question, as per my understanding of how T.C(which might be very wrong, so please don’t judge) is calculated by seeing how many times the loop will be running as the input grows.
So as per my thinking, T.C should be O(N2^(N-1)), as when we will process 3 it will run 4 times and when it will process 4 it will run 8 times.
Please help me understanding it. Moreover, my teacher is not responding to my questions, so that’s why I cam over here.