This time I'm describing my experience with recursive functions: writing, tracing in order, finding out what a function does. Generally, recursion is considered as a concept that is difficult to understand. However, this is not exactly true. It is true that "thinking recursively" is a skill that has to be practiced a lot in order to be mastered, but it does not involve anything beyond common sense and basic knowledge of programming. In short, recursion is an algorithm whereby a function calls itself. Once you're comfortable with how a function "sees" the data tha you pass to it and know what it does with a smallest subunit of data (e.g. a list), you can easily trace a call in order. So, tracing is relatively easy, unlike writing recursive functions. Sometimes it's difficult to find the right place for a recursion statement (i.e. when a function should call itself), sometimes it's challenging to squeeze the actual functionality in (i.e. where the function changes or creates its output). Several times I'd find myself having a function that has recursivity, that goes through the input the right way, but produces no output. Creating a variable that will be able to change itself depending on its value in "daughter" functions - this is what is tricky for me. At least, I don't breeze through this part every time, some functions and algorithms are easier to write than others.
To sum up, the whole concept of recursion is of high importance and can be applied anywhere you need (or don't need, just want) it. Yet, with high importance increased difficulty comes. A bad thing? Expectable, not more than that.
To sum up, the whole concept of recursion is of high importance and can be applied anywhere you need (or don't need, just want) it. Yet, with high importance increased difficulty comes. A bad thing? Expectable, not more than that.
Комментариев нет:
Отправить комментарий