If I had a function call itself, meaning it is recursive, would that factor into the time complexity of the function? Or if I had a function call another function, would that factor into the total complexity of the outside function? I did find some information about the recursive types of functions in CRLS, but I could not fully understand nor find about a function calling another function. What is the reasoning we should or should not as well?
Asked
Active
Viewed 30 times
1 Answers
0
The call itself doesn't need to be considered to add any time, but calculations involving the parameters and the time needed to execute the function should.
Why? O-complexity doesn't care how you express a certain algorithmic idea. You could fully unroll your loops, use stacks or function calls - only the actual instructions matter. No cheating.

Christopher Oezbek
- 23,994
- 6
- 61
- 85
-
would the call itself take constant time? – Time_Barber9960 Dec 09 '20 at 22:15
-
I would say it would not have to take up any time. It wouldn't matter though if you assign it constant time. – Christopher Oezbek Dec 10 '20 at 08:20