Recursion is an important topic in computer science. A function is RECURSIVE if it calls itself. A substitute for recursion when solving problems is using "looping" (iteration).
Why use RECURSION?
While recursion may appear mysterious at first, it is quite useful in computer science as it is concise and elegant whereas a solution involving iteration is complex and inelegant.
First steps with RECURSION:
To understand recursion, it is important to first learn to trace a recursive call. Trace a few examples with the smallest possible input. Once confident that recursion works for all problems of this size, it is best to check the next largest input. Confidence is key!
It is also important to consider "size". When tracing recursive calls, smaller code creates problems and it is important to study/examine this behavior.
Overall, recursion may take time to understand but examples will help with understanding greatly!
Feel free to leave a comment.
Until next time, will you believe?
Why use RECURSION?
While recursion may appear mysterious at first, it is quite useful in computer science as it is concise and elegant whereas a solution involving iteration is complex and inelegant.
First steps with RECURSION:
To understand recursion, it is important to first learn to trace a recursive call. Trace a few examples with the smallest possible input. Once confident that recursion works for all problems of this size, it is best to check the next largest input. Confidence is key!
It is also important to consider "size". When tracing recursive calls, smaller code creates problems and it is important to study/examine this behavior.
Overall, recursion may take time to understand but examples will help with understanding greatly!
Feel free to leave a comment.
Until next time, will you believe?
I want to believe
ReplyDelete