We trace from simple to complex, which gives a better standing of how a recursion works.
I added one more example here in depth with depth3, which really helped me understand what depth mean here.
I left a question for tracing it in week 5's slog, and now i figure out it have be no more than 3 steps for tracing it. And i won't make mistake on these kind of problem next time.
---------------------------
Recursive functions are functions that call themselves. They have a conditional structure that specifies a base case, a condition which will stop the function from making calls to itself. Also, recursion is actually a method of using stacks to achieve a task.
This general form of recursion gives me some idea about how to write recursion function.However, it is really difficult to actually write a recursion function when I start to write assignment 2.
No comments:
Post a Comment