Wednesday, January 28, 2015

Week4 Slog

This week, we had an introduction about recursion, which is the most confusing part for me in this course. In CSC108, and in CSC148 so far, we learned how to write programs and methods to work things out, but we can only use them when they are completely finished. However in recursion, it's completely opposite. We use the methods inside themselves as a part of the components before we finish writing them to make the methods repeatly doing the same thing. It is really comfusing for me that, how can a method work without being finished and how python read the code when the method is inside itself. But I think I will know how to do it perfectly at the end of this sememster by practising a lot and read many methods with recursion. This way, I will get very familiar with recursion and I will 'think recursively'.

1 comment:

  1. There is a way to resolve the problem of infinite recursion. It is to include the base case in your code. You design your code in a way that a recursive call will return the base case of the function, so that you get the necessary data to use for the final output of the code.

    ReplyDelete