educative.io

Educative

Recursive solutions increases time complexity?

Greater Time requirements

A also has greater time requirements , i.e., the run-time increases because each time the method is called, the stack grows and the final answer is returned when the stack is popped completely.

A recursive program also has greater time requirements . For example, the run-time increases because each time the method is called, and the stack grows and the final answer is returned when the stack is popped completely.


I literally couldn’t comprehend the explanation given above, not to mention the same thing is repeated twice. This part - “because each time the method is called, and the stack grows and the final answer is returned when the stack is popped completely” is talking about the increase in space requirements due to the stack, what does this have to do with why recursion causes greater time requirements?

I don’t understand these statements at all. I use recursion when it solves an algorithmic problem with less steps than nested loops, so it consumes less time. If a recursion is more worse than loops it isn’t worth to implement. This topic is a nonsense.