2016年2月25日星期四

recursion(week 7)

As the class processes on, we began to learn algorithm. recursion is a really interesting way to write program. I have found that we could use some simple but talented way to rewrite some complex code. When we use recursion, only few codes we need to write, and computer finishes anything left. it is really a new experience for me to write code. And this algorithm really gives me a new way to think how we should write code and how computer could do.

It's different with C or pascal, I found out that Python is really a better language. It's convenient and clear to show and let us understand how to write and figure out how computer works. But sometimes I still have to figure out these three different language. I often mass them up and make my codes incorrect. It's so lame.

The most important concept I learn is to use the function in the function.
ex:
if instance(L, list):
    return max([rec_max(x) for x in L])
else:
    return L

This is a convenient way to write recursion but it's hard for me to think about it.
Also, the dot product I learn during the TUT is helpful to understand the concepts and how we write loop in a different, efficiency way.

没有评论:

发表评论