This week's topic is going to be a continuation to lasts week's topic: Recursion. Last time I spoke about it I felt I was rushing the topic too much, but hopefully today I can elaborate on this matter. In the previous slog of mine, I tried to illustrate recursion through the an example where we had to gather all possible blood types for individuals across Canada. I will start by reexplaining the example and mentioning key terminology that I may have missed last time. Then I will talk about some things we covered in Week 4's lecture.
In the blood type example I tried to show a possible method, recursion, as a solution to a problem of determining what blood type everyone in Canada has. The idea is that we are dealt with a vast number of people, but each of these people are split into sub amounts of people in each province. Furthermore, we can yet again separate people by regions they live in within each single province in Canada. The pattern of taking the current problem and separating into similar problems, but smaller in size, is the idea of recursion. This circular method has to has a limit, or else we would go on forever. This limit is what we call a base case. In the previous example, I don't recall saying a base case. I think the base case in reality would be till we hit certain postal codes where we can send people to a near by school to register their blood type. It would be ideal that our base case would be the actual person, but there would be no affordable way to execute that in real life. Being that we are on a budget, as seen in the real world, I would determine that the base case would be the community surrounding the schools. From there the method would be forced to exit from its current recursive stage as it has hit the predetermined base case we placed in the function.
The preceding paragraph raised a couple concerns for me when I was writing, but I feel I should discuss them now. The professor also illustrated this concern which was what would happen if we never hit the base case. The answer seems pretty straight forward because it just implies the function will never exit itself. It will keep trying to keep converting the bigger problem into a smaller problem. An infinite loop that is missing a base case. I found the example Danny used with the turtles were very helpful.
I will write sooner next time, probably after the midterm. I will need to vent all my thoughts :P.
Have a goodnight everyone!
No comments:
Post a Comment