What is the difference between iteration and recursion?
Answers
Answered by
3
Recursion is a function calling itself.
Iteration is a set of instructions being executed repeatedly.
Recursion is slower because, each time the same function calls itself a new stack frame has to be created. And they all are to be removed after completion.
Whereas in iteration, the operation is carried out in the same stack frame.
Iteration is a set of instructions being executed repeatedly.
Recursion is slower because, each time the same function calls itself a new stack frame has to be created. And they all are to be removed after completion.
Whereas in iteration, the operation is carried out in the same stack frame.
Similar questions