Hi everyone,
This week we went into more depth on the topic of recursion - namely looking at recursion depth! I found the tree burst function very cool as it shows that recursion can be nice to look at as well as a cool concept. When I first heard about recursion, everyone seemed afraid to speak of it, but so far it hasn't been that bad. I was confused at first but now it makes a lot of sense programming-wise. I've also started seeing examples of it in my every day life.
We learned about recursion depth this week and it was interesting because it made me think of something my Calculus professor mentioned a few weeks ago. He said someone once asked the question "How long is the coast line of Nova Scotia?" People could give a rough approximation, but of course it's not perfectly straight all along the coast line. So for those places where it wasn't straight, you could zoom in and then it would be made up of a series of straight parts right? Well on each bumpy part, you zoomed in and there were more bumpy parts. And then you could zoom in on that and there would be more bumpy parts each time you zoomed in and this would happen infinitely. As a result, no one knows the length of the coastline of Nova Scotia! This is an example of infinite recursion depth:
def coastline_length(coastline):
return (sum ([length of segment for segment of coastline]) if segment is a line, else coastline_length(segment))
It is cool to see examples of recursion depth in every day life. Here is a picture of recursion in nature, seen in fractals (in this case a cauliflower!)
Have a good week!
No comments:
Post a Comment