← BYTES
Algorithms·Starter·Ref: 12.1.5
What is the difference between an iterative and a recursive approach to solving a problem?
Have a question about this video? Mention reference 12.1.5 when you contact us.
a.They always produce different final answers
b.Iterative uses loops to repeat steps; recursive has a function call itself with a smaller version of the problem, relying on a base case to stop
c.Recursive approaches never use any memory
d.Iterative approaches cannot be used for any problem recursion can solve
An iterative solution uses loop constructs to repeat work with explicit state variables; a recursive solution has the function call itself on a smaller sub-problem, with a base case that stops the recursion -- many problems can be solved either way, with recursion often expressing certain algorithms (e.g., tree traversal) more naturally at the cost of call-stack overhead.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES1215#Algorithms